Robert,
thanks for your answer.
>> has_many :children, dependent: :destroy, -> { order 'id asc' } do
>
> This line looks wrong to me. You have a lambda arrow (-> with it's block
> { ... } and immediately trying to open another block with do. Written a
> slightly different way it might look something like:
>
> has_many :children, dependent: :destroy, -> do order 'id asc' end do
It's interesting, because this line:
has_many :children, -> { order 'id asc' } do
works fine (except at destroying associated records, of course), so it
seems it's not a problem with two blocks, right?
> Here's an example that maybe shows what you're trying to do:
>
> has_many :tracks, -> { order "position" }, dependent: :destroy
>
> In this case it appear to me the lambda function is in the "scope"
> argument with options following and no block.
I don't understand what you mean with this, did you miss the "do" at the
end of the line. Anyways, I tried the order I think you are suggesting:
has_many :children, -> { order 'id asc' }, dependent: :destroy do
with no luck. So it seems that I have to choose between having 2 out of
the 3 things I need.
--
Posted via http://www.ruby-forum.com/.
--
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/aae49a06cfa2fdd4cc0f105fe846d470%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment