Skip to main content

Creating a Blog with Images ins Posts

Rails • Asked by Sebastian

Hey folks,
iam very new to Ruby on Rails but iam trying to improove my skills.
I want to write a little blog application on rails where i should have the ability to create posts. I followed a pretty nice guide on youtube so i have set up a blog which works okay for posts in general. i implemented tinymce as texteditor.
i really want to have the ability to upload images in my posts, so when i ll upload a post that i can fill in a few images. AS seemed to be a good solution, but i am only able to attach files after posts not in my posts. i also tried trix and shrine but somehow its not working. maybe cause my postmodel isnt right therefore? i have a t.text :content and t.string :title there.

is there an opportunity to insert images IN posts with AS?

my main goal is and my pretty naiv idea was to create posts with images and have a page called image gallery where every image is automatically added so you can see an overview over all images.
on the home i wanted to have images as kind of "teasers" for my posts. so the image has a description and a title and when you vlick on it you get to the single post view.
is that even realistic? i am really stuck right now which is sad cause its totally frustrating. iam very pleased for every tip! thank you so much!


You can use a WYSIWYG editor with an ability to insert images.

First go Here
https://github.com/spohlenz/tinymce-rails
Then Here
https://codepen.io/nirajmchauhan/pen/EjQLpV


Thank you for that source! Where do i have to fill this code in exactly? Is it enough to just add the css and the js to the tinymce.js and css? And how do i have to fill in the html?
In addition to that do i need something like shrine or is AS enough for my goals?


What version of Rails are you using?


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.