-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
position: 0 now makes model pushed to top? #110
Comments
For now, fixed my issue with move_to_bottom function in the controller. |
Any suggestions to set "new items at the bottom of the list" as a default behaviour? |
Let me look at this. What is your gem version?
|
|
Is this related to #109 ? |
I had this issue as well, and I fixed it (for my use case, at least) with the following mixin: module ActsAsListFix
# clear the default position value, because having it present
# causes acts_as_list to insert the record at that position
def self.included(base)
base.after_initialize do
if new_record? && (pos = send(position_column)) &&
pos == self.class.column_defaults[position_column]
send("#{position_column}=", nil)
end
end
end
end Just place the class Floor < ActiveRecord::Base
acts_as_list scope: :building_id
include ActsAsListFix
end This is an update to my solution to this problem from a few years ago. That wasn't working for me anymore after upgrading to Rails 4.1 and Ruby 2.1, but this new one is working for me so far. Hopefully this behavior of ignoring the default value of the |
Is this still a problem? Instead of a monkey patch it'd be good if we could fix it. New items should go at the bottom of the list by default. Have you tried removing the default value from that column? |
Sorry, i'm not having access to that project anymore. |
Ok, I'll close this. If someone can reproduce this with a failing test then we'll look into it. |
After update i got weird issues with sorting.
After investigation i have found that new items got pushed to top, and not to bottom as described...
So model with position: 0 results into position: 1.
Is this new behaviour, or i have some issues in my code? Maybe with scope(i have scope on multiple fields) but how it relates to this?
The text was updated successfully, but these errors were encountered: