Hi Andrei,
Thanks for the quick feedback.  I changed all prepsteps to prep_steps,
but now I'm getting an uninitialized constant error in my Recipe
controller for the following line:
    3.times { @recipe.prep_steps.build }

BROWSER DISPLAY:
   NameError in RecipesController#new
   uninitialized constant Recipe::PrepStep

ERROR FROM THE CONSOLE:
  NameError (uninitialized constant Recipe::PrepStep):
    app/controllers/recipes_controller.rb:28:in `new'
    app/controllers/recipes_controller.rb:28:in `times'
    app/controllers/recipes_controller.rb:28:in `new'
    -e:1:in `load'
    -e:1

I took out the 3.times & curly braces & tried just the
"@recipe.prep_steps.build" and I got the same error.  I changed the
prep_steps to a number of variations (prepsteps, PrepSteps, PrepStep)
and got other various errors.  Any thoughts?  Is the underscore the
issue?
Thanks in advance!
Seth


On Dec 11, 1:26 am, Andrei Erdoss <[email protected]> wrote:
> 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-1which 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.


Reply via email to