1,840 Experience
0 Lessons Completed
2 Questions Solved


Posted in Creating a Blog with Images ins Posts

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!

I really need help with trix, i dont know what iam doing wrong, but Trix isnt working for me in Rails 5.2.
I did everything like in the setup explained but i had my postmodel before.
so as you can see i have a field called t.text "content" - and everywhere trix is referring to a body. Is that the issue? How can i change the migration so that my content is a body? And! If that even needed? I mean if i switch in my code body for content it is supposed to work aswell right?

My Schema looks like this:
create_table "posts", force: :cascade do |t|
t.string "title"
t.text "content"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "slug"
t.index ["slug"], name: "index_posts_on_slug", unique: true