>From a quick glance at your code, I see that you use prepsteps in your controller and pre_steps in your models.
On Fri, Dec 11, 2009 at 5:28 AM, SousChef <[email protected]> wrote: > So I'm a newbie to Rails and attempting to add multiple models to a > form. > > I found the Railscast for "Complex Forms, Part 1" at > http://railscasts.com/episodes/73-complex-forms-part-1 which is from > 2007 and at the point where the moderator, Ryan, says "Let's take a > look at our code..." and refreshes the UI and in the Railscast we see > 3 Tasks below the Project. However, when I refresh my project screen, > my code shows a "NoMethodError" in the Controller with an undefined > method for the prepsteps that were added. I'm not following the > Project/Task models, but am building a Recipe/Preparation Steps models > to learn Rails. Not sure what's up except my controller needs a method > somewhere. I'm using Rails 2.3.4. Any sugggestions? > > Thanks in advance!! > -------------------------------------- > > Error message: > NoMethodError in RecipesController#new > > undefined method `prepsteps' > > Following is my code: > recipes_controller.rb > def new > @recipe = Recipe.new > 3.times { @recipe.prepsteps.build } > > respond_to do |format| > format.html # new.html.erb > format.xml { render :xml => @recipe } > end > end > > recipes\new.html.erb > <% for prepstep in @recipe.prepsteps %> > <% fields_for "recipe[prepstep_attributes][]", prepstep do | > prepstep_form| %> > <p> > <%= prepstep_form.text_field :step_number %> > <%= prepstep_form.text_field :step %> > </p> > <% end %> > <% end %> > > recipe.rb > class Recipe < ActiveRecord::Base > validates_presence_of :name > > has_many :prep_steps, :dependent => :destroy > > accepts_nested_attributes_for :prep_steps > end > > prep_steps.rb > class PrepSteps < ActiveRecord::Base > has_one :recipe, :dependent => :destroy > > validates_presence_of :recipe > end > > -- > > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]<rubyonrails-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- Andrei Erdoss -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

