I am building a blog that allows me to post pictures, and when a new post w/ a picture comes up, I get an error saying "require attr_accessor for 'image_file_name'". So I put my "attr_accessor :image" in there and I get an "undefined method error 'attr_accessor'". https://github.com/BBaughn1/savagelysaving <-- the github if you need it
def create
@post = Post.new(post_params)
if @post.save
redirect_to @post
else
render 'new'
end
end
This is before the error,
def create
attr_accessor :image
@post = Post.new(post_params)
if @post.save
redirect_to @post
else
render 'new'
end
end
and this is after the error. And, I got this error earlier but fixed it with this:
def update
@post = Post.find(params[:id])
attr_accessor :image
if @post.update(params[:post].permit(:title, :body, :image))
redirect_to @post
else
render 'edit'
end
end
putting "attr_accessor :image" before the "@post = Post.new(post_params)" will give me the same error saying that I require "attr_accessor"