I’m pretty newbie in ruby and I’m not sure that the question be suitable, but this is my problem.
I have a function with unlimited string parameters. I want to know if all of them are in the http request. This is my code :
def http__params_exists *list
list.each do |p|
if params[:'#{p}'].nil?
return false
end
end
true
end
Take an example : I have a query with the “lat” parameter. The condition that I want to be execute is if params[:lat].nil?
I tried some tricks, but all failed.
Thanks.
ps :An other question about ruby. I don’t know exactly the kind of objects that symbols like :method_not_allowed (for example) are. I know that we can call a function naming some parameters, but this object is already defined somewhere, as if it was a public variable of the controller, but it doesn’t seems to be.
You need to use
"instead of'so that the variable is interpreted. ExampleSo, your code shall be
This is an interesting link to learn more about Ruby symbols.