我的搜索中有几个条件。
@events = Event.search(params[:search],
:conditions => {:group_size => 1, :days => 1})
上面的代码工作正常。但是,如果我想用私有方法替换散列,我会收到语法错误
syntax error, unexpected ',', expecting tASSOC
:conditions => {group_size_condition, :days => 1},
代码如下
@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
提前致谢