On 15 February 2010 10:46, David Krett <[email protected]> wrote:
>
> I am a ruby on Rails Novice and I am having an extremely frustrating problem
> - not sure whether acts_as_tree plug in is causing this or not (or me lacking
> a fundamental misunderstanding of rails)
>
> Everything works when I test the above code in the Rails console however when
> running the server the children are failing to have the commission_rate
> variable updated.
> Would appreciate any help anyone can provide me.
>
You're not saving the child after you update it's value
for child in @children do
child.commissions_rate = @rate
child.save
end
or
for child in @children do
child.update_attribute(:commissions_rate, @rate)
end
.update_attribute automatically saves, check the Rails API docs for
more info on using this method.
PS You're using a lot of instance variables there, which seem like
there would be better scoped as local variables (ie drop the @ from
the variables unless you need them to be accessible on an instance of
the object - @destination is probably the only legitimate instance
variable)
--
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.