I am using Paperclip, and my only problem is that in my image tag, I have an undefined method "image".
<%= image_tag @posts.image.url(:medium) %>
is where my error is occurring. When I loaded a new migration, I accidentally did "rails g paperclip user image" instead of "rails g paperclip posts image" so I went into my code and changed "user" to "posts." I asked something similar and someone mentioned that it was with my schema.rb file(?).
Just to be safe, this is my post_params:
private
def post_params
params.require(:post).permit(:title, :body, :image)
end
but here is my migration file:
class AddAttachmentImageToUsers < ActiveRecord::Migration
def self.up
change_table :posts do |t|
t.attachment :image
end
end
def self.down
remove_attachment :posts, :image
end
end
Aucun commentaire:
Enregistrer un commentaire