On 24 August 2014 12:44, Jaimin Pandya <lists@ruby-forum.com> wrote:
> Colin Law wrote in post #1155814:
>> On 24 August 2014 08:25, Jaimin Pandya <lists@ruby-forum.com> wrote:
>> We went all round this last time you tried to ask this question a
>> little time ago. You must show us the code where you set
>> @line_item.expensescounter. The above code does not do that, it is
>> just a private method of the controller that returns an
>> Expensescounter object. If you do not understand what I am asking
>> then please say so.
>
> Which code should i show you that i am not understand.
You have a variable called @line_item and are trying to reference the
member @line_item.expensescounter. I assume that @line_item is an
object of class LineItem. Is that correct?
Assuming the above is correct then what is LineItem.expensescounter?
Is it an association, so in the lineitem class you have lineitem
belongs_to Expensescounter or has_one Expensescounter? If so then at
some point you should have made an expensescounter and assigned it to
a lineitem object and saved them both in the database. Your error
suggests that the lineitem object in @line_item does not have an
associated expensescounter. So the code you need to show is how you
create the expensescounter and then give it to the lineitem. All you
have showed so far is a public method (current_expensescounter) which
finds or creates one, but there is nothing to say that it belongs to
the particular lineitem referenced by @lineitem.
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtcihO_8BsC2WUWpk%3Dm9iPMZG8eCh1SQ-pQdwECUAxSpw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment