Closed oyeanuj closed 6 years ago
Hi @oyeanuj, it definitely looks like acts_as_list isn't being required for some reason (or at least the acts_as_list
method isn't being added to ActiveRecord::Base.
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 config/application.rb
if that helps: https://gist.github.com/oyeanuj/6b6db7f6b239c00f6039883bb3969919
Thanks @oyeanuj :) It doesn't look like you're loading in active_support
though I can't be sure. Perhaps that's always loaded anyway? If it's not, that might be the reason why the on_load
callback isn't being called and thus aal
isn't loading. Can you do some investigation down that track? Perhaps you only need to include a small part of active support to do with loading?
So, it seems like ActiveSupport.onLoad
is being called. In one of the initializer files, I added the following code which got printed:
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.
@brendon @bevinh I haven't had a chance to go back to this but I am hoping to do this soon.
@bevinh If you are able to test out the suggestion above sooner, that would be great!
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.Added the following code snippet.
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?