You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you very much for maintaining this gem. Have a use case that could maybe use a little love (I know it's been discussed before, but not enough it seems).
We have acts_as_list declared like this:
acts_as_listscope: [:active]
In DB position default is set to 1, but the problem is: each new record still goes to the bottom. Setting position to 1 explicitly, or using position_will_change! doesn't help (probably because it's equal to what's already set by default). A note in the README says this is normal, and refers to "recent discussions", however, that note was written in 2011, and I couldn't find any discussion that helps work around this, would appreciate some help.
I did also try adding add_new_at: :top, but with that the problem is that it always goes to the top, even when a position is provided.
I managed to hack together this workaround, the downside being that I have to use this method instead of standard AR create, and it has to do the creation in 2 DB interactions.
class << selfdefcreate_at_position(params, &block)transactiondoitem=create(params, &block)item.move_to_topunlessparams[:position]endendend
Wonder if there is better way to do this that I could at least help document.
The text was updated successfully, but these errors were encountered:
Thank you very much for maintaining this gem. Have a use case that could maybe use a little love (I know it's been discussed before, but not enough it seems).
We have acts_as_list declared like this:
In DB position default is set to 1, but the problem is: each new record still goes to the bottom. Setting position to 1 explicitly, or using
position_will_change!
doesn't help (probably because it's equal to what's already set by default). A note in the README says this is normal, and refers to "recent discussions", however, that note was written in 2011, and I couldn't find any discussion that helps work around this, would appreciate some help.I did also try adding
add_new_at: :top
, but with that the problem is that it always goes to the top, even when a position is provided.I managed to hack together this workaround, the downside being that I have to use this method instead of standard AR create, and it has to do the creation in 2 DB interactions.
Wonder if there is better way to do this that I could at least help document.
The text was updated successfully, but these errors were encountered: