On 5 August 2014 11:59, Jaimin Pandya <li...@ruby-forum.com> wrote:
>> As I have already said you need to debug or show us the code where you
>> tell the individual line item that it owns that particular
>> expensescounter (or the code where you tell the expenses that it
>> belongs to that particular line item, whichever way you do it).
>>
>> Presumably somewhere you have called current_expensescounter to create
>> it, but then what have you done with it?
>
> I have used current_expensescounter method in application_controller.rb
> file.
>
> Then current_expensescounter use in create method of
> line_items_controller.rb file to add selected quantity to
> expensescounter. like as follow:
>
> def create
>     @expensescounter = current_expensescounter
>     quantity = Quantity.find(params[:quantity_id])
>     @line_item = @expensescounter.add_quantity(quantity.id)
>     @line_item.quantity = quantity
> .
> .
> .
> .
> .
> end
>
> In above code i used add_quantity, that method i define in
> expensescounter.rb file like as follow:
>
>  def add_quantity(quantity_id)
>     current_item = line_items.find_by_quantity_id(quantity_id)
>     if current_item
>        current_item.expense += 1
>     else
>        current_item = line_items.build(quantity_id: quantity_id)
>     end
>     current_item
>   end



I still don't see the code that adds @expensescounter to @line_item.
Can you point to a particular line that does this?

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+unsubscr...@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%3D0gLviPZB10of%2BJKn%3D2-9sATKc_80c2k82gzghLG%2B-akOOFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to