I have several conditions in my search.
@events = Event.search(params[:search],
:conditions => {:group_size => 1, :days => 1})
The above code is working fine. However, if I want to replace the hash with a private method, I get syntax error
syntax error, unexpected ',', expecting tASSOC
:conditions => {group_size_condition, :days => 1},
Code is as follow
@events = Event.search(params[:search],
:conditions => {group_size_condition, :days => 1})
private
def group_size_condition
if params[:groupsize] == 'single (1)'
:group_size => 1
elsif params[:groupsize] == 'couple (2)'
:group_size => 2
elsif params[:groupsize] == 'small group(3-5)'
:group_size => 3..5
else
nil
end
end
Thanks in advance