Reputation: 67
really quick i got this error: "syntax error, unexpected tIDENTIFIER, expecting ')'", when im trying to use these code to find a value in a db (im just learning ruby).
def load_leagues
@men_leagues = League.where(kind: 'men').order('id ASC').find_all
@men_active_leagues = League.where(active: true AND kind: 'men').order('id ASC').find_all
@women_leagues = League.where(kind: 'women').order('id ASC').find_all
@current_user = current_user
end
I think that the line of @men_active_leagues is the one giving me troubles.
Thanks for everything!
Upvotes: 0
Views: 1284
Reputation: 4465
There is no AND
operator in ruby.
To use AND
in a where statement you could either specify both the arguments.
@men_active_leagues = League.where(active: true, kind: 'men').order('id ASC').find_all
or you could specify it as a string
@men_active_leagues = League.where("active = TRUE AND kind = 'men'").order('id ASC').find_all
Upvotes: 1
Reputation: 73659
Resolved in following, self-explanatory, hash composition was wrong:
def load_leagues
@men_leagues = League.where(kind: 'men').order('id ASC').find_all
@men_active_leagues = League.where({active: true, kind: 'men'}).order('id ASC').find_all
@women_leagues = League.where(kind: 'women').order('id ASC').find_all
@current_user = current_user
end
Upvotes: 0