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

acts_as_list :scope => "doesnt_seem_to_work" #12

Closed
holden opened this issue Aug 25, 2011 · 3 comments
Closed

acts_as_list :scope => "doesnt_seem_to_work" #12

holden opened this issue Aug 25, 2011 · 3 comments

Comments

@holden
Copy link

holden commented Aug 25, 2011

I'm trying to use acts_as_list in combination with has_ancestry, but when I apply a scope it returns this:

Code: acts_as_list :scope => "ancestry" #string column

Returns:

ActiveRecord::StatementInvalid in FaqsController#create

PGError: ERROR: argument of WHERE must be type boolean, not type character varying
LINE 1: SELECT "faqs".* FROM "faqs" WHERE (ancestry) ORDER BY posit...
^
: SELECT "faqs".* FROM "faqs" WHERE (ancestry) ORDER BY position DESC LIMIT 1

@swanandp
Copy link
Collaborator

:scope in acts_as_list works just like it does in validates_uniqueness_of. i.e. if its a string, it is expected to be a SQL fragment. Can you try :scope => :ancestry and see if it works?

@holden
Copy link
Author

holden commented Aug 25, 2011

I think I found a fix from the ancestry wiki. I'm trying it out now, and so far it's working. I tried using :scope => :ancestry, but it didn't work for some reason which now escapes me.

has_ancestry :cache_depth =>true
acts_as_list :scope => 'ancestry = '#{ancestry}''
named_scope :ordered, :order => "ancestry_depth,position DESC"

https://github.com/stefankroes/ancestry/wiki/arrangeAsList

Thanks for the quick reply!

@swanandp
Copy link
Collaborator

Ok, good to know it works!

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

No branches or pull requests

2 participants