Hi, having a few problems working out whats kicking off, im using validates_presence_of :title in a models class this seemed to work fine untill I used a custom new.rhtml error message I am gaining is NoMethodError in Recipe#create Showing app/views/recipe/new.rhtml where line #15 raised: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occured while evaluating nil.each 12: <p> 13: <b>Category:</b><br/> 14: <select name="recipe[category_id]"> 15: <% @categories.each do |category| %> 16: <option value="<%= category.id %>"> 17: <%= category.name %> 18: </option> the def create controller looks somthing like this def create @recipe = Recipe.new(@params['recipe']) @recipe.date = Date.today if @recipe.save redirect_to :action => 'list' else render_action 'new' end end any suggestions to where im going wrong?
on 2006-04-19 14:26
on 2006-04-19 14:36
It looks like you need to get @categories in your create method so that it will be available in your template.