-
-
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
Scope for Polymorphic association + ManyToMany #106
Comments
Hm... i guess i need to define position on the join model itself for that to work... |
I think the gem should support lambdas for scopes. With that, you can just define your own scope. |
Polimorphic relation(or maybe all relations) is scopes by itself. So i have defined polimorphic relation as "holder". So asset has holder, wich can be either Topic or Comment... This way i just do belongs_to :holder, polymorphic: true
acts_as_list scope: :holder And all works... Still lambdas may be a good idea = ) |
I use it the same way:
However Rails 4 complaints:
What would be the right syntax here? |
Even worse Rails 4.1 simply rejects it:
Suggestions? |
Anyway, I did it like this:
|
Okay, upon further investigation I have figured out that it simply doesn't work. It reorders all images ignoring the scope. Switched to |
Probably worth checking, however this is for Rails 3 http://jakeboxer.com/blog/2011/10/09/using-acts-as-list-in-a-polymorphic-scope/
|
@firedev hm, strange... i didn't had this issue... just used as usual scope... |
acts_as_list scope: [:imageable_id, :imageable_type]
This worked in rails4! |
Guess this was fixed since. |
Closing. |
I have this setup: "Topic" and "Comment" has many "Assets" through polymorphic join table.
I want my topics and comments to have their assets ordered. To make my act_as_list work for Topics and Comments separately it should use default scope. How to do that?
The text was updated successfully, but these errors were encountered: