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
精彩评论