Reputation: 851
I am using Rails 4 application
where query use includes.
Query: @courses = Course.includes(:translations).unpublished_status
Where unpublished_status
is scope write in Model. (See Below):
scope :unpublished, -> { where(published: false) }
scope :status, -> { where.not(status: 'active') }
scope :unpublished_status, -> { unpublished.where.or(status)}
When i run code then got below error:
NoMethodError at /api/v1/unpublished_courses
============================================
> undefined method `or' for #
<Globalize::ActiveRecord::QueryMethods::WhereChain:0x007fe05dbc70d8>
Where is actual issue did not found. Any one have a idea on it.
Thanks
Upvotes: 1
Views: 112
Reputation: 720
where.or
is available only in rails 5 you can check this link.
To 'OR' scopes you can do :
scope :unpublished_status, -> { unpublished || status}
**OR**
Course.where('published = ? OR status != ?', false, 'active')
Upvotes: 1
Reputation: 10358
undefined method `or' for #
<Globalize::ActiveRecord::QueryMethods::WhereChain:0x007fe05dbc70d8>
As it says undefined method
for ActiveRecord::QueryMethods::WhereChain:
means or method
is not available. To fix this or_scopes.rb , you'd be able to OR your scopes.
Hope this helps you !!!
Upvotes: 0