hello colin,
thanks for your reply,
i know what that error means.... but my problem is why this is comming
& how can i achieve my solution.



more details:

1) content_master model:

class ContentMaster < ActiveRecord::Base
     has_one :Metadata
end

2) metadata model:

class Metadata < ActiveRecord::Base
    belongs_to :ContentMaster, :class_name => 'ContentMaster'
end

3) new action in controller

def new
    @content_master = ContentMaster.new
    @metadata = @content_master.Metadata.build

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @content_master }
    end
end

4) oops same error
undefined method `build' for nil:NilClass


i hope now my problem is more clear

looking forward for help

thank you



On Mar 3, 1:47 pm, Colin Law <[email protected]> wrote:
> On 3 March 2010 18:21, mac <[email protected]> wrote:
>
> > hello,
> > m following 
> > railcasthttp://media.railscasts.com/videos/073_complex_forms_part_1.mov
>
> > but i am getting error:  undefined method `build' for nil:NilClass
>
> If you look on the line in your code where the error occurs you will
> likely find that you are using something.build.  The error is
> indicating the your 'something' is nil.
>
> If you cannot see why it is nil it might be worth your while looking
> at the rails guide on debugging athttp://guides.rubyonrails.org.
> This shows various methods of debugging your code.  For example you
> can use ruby-debug to break into your code and inspect your data to
> see what the problem is.
>
> Colin
>
>
>
> > can you please help
>
> > though m using belongs_to and has_one relationship rather then
> > "has_many" is this the problem ???
>
> > if you want i can provide more details
>
> > thank you
>
> > --
> > 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 
> > athttp://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
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