开发者

Rails - Iterating through method names

I'm trying to figure out how to iterate through method names in my controller. This is what I have so far but of course this won't work. I've seen other posts about using 'send'. But couldn't get that to work right. Any suggestions?

@someMethods = {
 开发者_JAVA百科 '0' => 'methodone',
  '1' => 'methodtwo'
}

for count in 0..1
  @someObject[count] = Trucks.@someMethods["#{count}"](params[:color])
end


@someMethods.each do |count, method|
  @someObject[count] = Trucks.send(method, params[:color])
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜