undefined method `map' for nil:NilClass , what causes this?

<%= collection_select(:book,:subject_id,@subjects,:id,:name) %>

Your @subjects object is undefined. You need in your controller action for this page something that sets the contents of that variable, for example:

@subjects = Subject.all 

See the source for options_from_collection_for_select - first thing it does is a map call on the collection passed to it (in your case @subjects).


<%= collection_select(:book,:subject_id,Subject.all,:id,:name) %>