Skip to content
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

insert_at doesn't seem to be working in ActiveRecord callback (Rails 4.2) #150

Closed
jasonsof opened this issue Jan 16, 2015 · 3 comments
Closed

Comments

@jasonsof
Copy link

Trying to reorder a list inside of an after_create callback doesn't seem to do any reordering. I created a little example with an rspec test in it.

https://github.com/jasonsof/acts-as-list-example

Is this normal, or am I doing something wrong here?

@brendon
Copy link
Owner

brendon commented Jan 16, 2015

Hi Jason, There's an option you can pass to your acts_as_list call :add_new_at => :top which should do what you're trying to do. It's not documented I don't think, but the code is here:

https://github.com/swanandp/acts_as_list/blob/master/lib/acts_as_list/active_record/acts/list.rb#L38

@jasonsof
Copy link
Author

Thanks Brendon, that option was exactly what I needed!

@brendon
Copy link
Owner

brendon commented Jan 16, 2015

You're welcome :) I've found altering the current record in after_creates
is always a hassle. There always seems to be some unforeseen consequence.
Better to override the attribute setter or something like that instead (not
in this case though!).

Brendon Muir

On Fri, Jan 16, 2015 at 11:08 AM, Jason notifications@github.com wrote:

Thanks Brendon, that option was exactly what I needed!


Reply to this email directly or view it on GitHub
#150 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants