-
-
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
NoMethodError: undefined method `acts_as_list' #303
Comments
Hi @oyeanuj, it definitely looks like acts_as_list isn't being required for some reason (or at least the The class methods are added via this: So if active_record isn't loading then perhaps that's the problem. Since you're restricting what parts of Rails are loaded, can you double check that you're indeed loading ActiveRecord? and doing it the right way? :) |
@brendon Thanks for the quick response! That makes sense but I am not sure why that might be happening since I've tested it with a clean Rails-API mode which includes ActiveRecord (I use it everywhere!) Here is my |
Thanks @oyeanuj :) It doesn't look like you're loading in |
So, it seems like ActiveSupport.on_load(:active_record) do
ap "Please work"
end In general, FWIW, here is the list of middleware that an API-app comes with, by default: http://edgeguides.rubyonrails.org/api_app.html#choosing-middleware Any ideas on what might be going on, given all of this? Appreciate you taking the time to figure this out! |
No worries :) In that case what I'd do next is clone a local copy of acts_as_list and update your gem file to refer to that. Then you can start playing around with how the gem is loaded to see if you can figure out where it's going wrong. Try adding a logging line in our on_load callback to see if that logs anything etc... It could be that we're initialising incorrectly somehow but hard to say :D |
Not working for me either. Did you find a fix @oyeanuj? |
Hi @bevinh, can you try the suggestion in my last comment? You need to pinpoint the loading sequence problem so we can figure out a way around it. |
I've just noticed that it works if it's scoped (e.g. acts_as_list scope: :list) but does not if it isn't. I was using an example from GoRails where the main list was just used with acts_as_list (no scope). I'm not sure what the intention of not scoping it is in that tutorial. I haven't had a chance to dig much deeper, as I'm working on a different app right now, but hopefully that is helpful. Did something change that requires the scope? |
Lol, I've never known it not to require a scope :) I suppose it doesn't need one though. I'm not even sure there's tests for that... Might be something to investigate if you have the time :) |
@brendon Sorry for the delay here. So, to your question about ActiveSupport, it is being loaded: [8] pry(main)> defined?(ActiveSupport.on_load)
=> "method" It doesn't seem like API-only apps do anything to ActiveSupport Thoughts on what else might be going on? Anything related to @bevinh's comment above? |
The only idea I have is to build a new empty (full) rails app. Then confirm it works with acts_as_list. Next start stripping off the bits you don't need and check if it works as you remove each bit. That should at least help you isolate the problem. Let me know how you get on. |
It worked once I upgraded to Rails 5.2 ¯_(ツ)_/¯ Thanks for your help! |
SO weird! :D Glad you got it to work :) |
Hey @brendon, I ran into an issue which feels awkwardly similar to #176 but the solution mentioned there doesn't seem to work for me.
I am on Rails 5.1.4 (API-only mode), and did the following as per the README:
position
in the intended model.I assume I am missing some obvious step, but can't seem to figure out what that might be. I went through #176, and the solution mentioned there to include
include ActiveRecord::Acts::List
throws a different kind of error for me.Any thoughts on what might be going on are super appreciated?
The text was updated successfully, but these errors were encountered: