Hello, I'm working to install the acts_as_commentable plugin on my Rails 3 app.
After adding "acts_as_commentable" to my book model, I then added a comment form on my book show view:
<% form_for(@comment) do|f| %>
<%= f.hidden_field :book_id %>
<%= f.label :comment %><br />
<%= f.text_area :comment %>
<%= f.submit "Post Comment" %>
<% end %>
Then in the controller (comments_controller.rb),
def create
@comment = Comment.new(params[:comment])
Book.comments.create(:title => "First comment.", :comment => "This
is the first comment.")
end
Then when submitting a comment, it returns the error: "unknown attribute: book_id" From the log:
Processing by CommentsController#create as HTML
Parameters: {"comment"=>{"comment"=>"WOOOW", "book_id"=>"32"},
"commit"=>"Post Comment",
"authenticity_token"=>"5YbtEMpoQL1e9coAIJBOm0WD55vB2XRZMJa4MMAR1YI=",
"utf8"=>"✓"}
Completed in 11ms
ActiveRecord::UnknownAttributeError (unknown attribute: book_id):
app/controllers/comments_controller.rb:3:in `new'
app/controllers/comments_controller.rb:3:in `create'
Suggestions?