# Having Problems with collection\_sellect

**URL:** <https://www.ruby-forum.com/t/having-problems-with-collection-sellect/185823>\
**Category:** Rails\
**Created:** [March 26, 2010, 6:48pm UTC](https://www.ruby-forum.com/t/having-problems-with-collection-sellect/185823 "2010-03-26T18:48:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gordons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/2bfe46/32.png) [@Gordons](https://www.ruby-forum.com/u/Gordons)\
**Post date:** [March 26, 2010, 6:48pm UTC](https://www.ruby-forum.com/t/having-problems-with-collection-sellect/185823/1 "2010-03-26T18:48:25Z")

</div>

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:

# Add new book
\<% form\_tag do %\> \<%= 'create' %\>

Title: \<%= text\_field\_tag 'book', 'title' %\>

Price: \<%= text\_field\_tag 'book', 'price' %\>

Subject: \<%= collection\_select(:book,:subject\_id,@subjects,:id,:name, :prompt =\> true) %\>

Description  
\<%= text\_area 'book', 'description' %\>

\<%= 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\>

---

<div class="post-metadata">

**Author:** ![Gordons](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/2bfe46/32.png) [@Gordons](https://www.ruby-forum.com/u/Gordons)\
**Post date:** [March 26, 2010, 7:07pm UTC](https://www.ruby-forum.com/t/having-problems-with-collection-sellect/185823/2 "2010-03-26T19:07:09Z")

</div>

On 26 March 2010 17:46, Gordons [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Price: 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\>

That would appear to be saying that the book class does not have a  
field subject\_id

Colin
