Straight to the question.
I have a query like this:
@issue_books = current_user.issue_books
@already_issues = @issue_books.taken(params[:id])
where taken is a named_scope defined as below:
scope :taken, lambda { |book_id| where(returned: false).where(book_id: book_id) }
Now everytime I run this query:
@issue_books.taken(params[:id])
I get an ArgumentError: wrong number of arguments (1 for 0) error.
If I rename taken to something else like taken_books, all seems to work fine.
So my question is: is taken a keyword in ruby? If not can anyone explain this behavior?
It is not a ruby keyword, but it appears to be a method defined on scopes.
Try this:
So the scope
takenyou have defined is probably overshadowed by a definition inActiveRecord::Delegate.Update:
I did some digging, and
takenseems to be defined as an alias forlimitinArel::SelectorManager, a dependency ofActiveRecord.