Hello everybody, I am new to Ruby on Rails, while going through one of
the tutorials, i found this program which I've been finding very
difficult to run and see the output as it has been throwing many
errors. Please can someone look into the codes and tell me how to
debug it:
<h1>Add new book</h1>
<% form_tag do %>
<%= 'create' %>
<p><label for="book_title">Title</label>:
<%= text_field_tag 'book', 'title' %></p>
<p><label for="book_price">Price</label>:
<%= text_field_tag 'book', 'price' %></p>
<p><label for="book_subject">Subject</label>:
<%= collection_select(:book,:subject_id,@subjects,:id,:name, :prompt
=> true) %></p>
<p><label for="book_description">Description</label><br/>
<%= text_area 'book', 'description' %></p>
<%= submit_tag "Create" %>
<% end %>
<%= link_to 'Back', {:action => 'list'} %>
The errors it throws are:
NoMethodError in Book#new
Showing app/views/book/new.rhtml where line #9 raised:
undefined method `subject_id' for #<Book id: nil, created_at: nil,
updated_at: nil>
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment