On 4 March 2010 12:19, mac <[email protected]> wrote:
> 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.

Did you try my suggestion to use ruby-debug?

>
>
>
> more details:
>
> 1) content_master model:
>
> class ContentMaster < ActiveRecord::Base
>     has_one :Metadata

That should be :metadata not :Metadata

> end
>
> 2) metadata model:
>
> class Metadata < ActiveRecord::Base
>    belongs_to :ContentMaster, :class_name => 'ContentMaster'

That should be :content_master and then the class name will not be needed

> end
>
> 3) new action in controller
>
> def new
>   �...@content_master = ContentMaster.new
>   �...@metadata = @content_master.Metadata.build

Should be metadata again.

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

It might be worth your while having a look at the ActiveRecord
Associations guide aswell as the debugging one.  That will explain how
to use associations.

Colin


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

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