I am using Ruby on Rails 3.
In my controller I have (can I have?!):
def action_name(variable_name)
...
end
How can I pass the value of the "variable_name" using this syntax
[...] :url => { :action => :action_name("name") } [...]
? Is it possible?
In view: :url => {:action => :action_name, :variable_name => 'dog'}
In controller:
def action_name
variable_name = params[:variable_name]
@something = Something.where(:name => variable_name)
#More code in this method
end
This code will pass variable_name as a part of querystring in URL: http://site.com/something?variable_name=dog
Obviously, don't use this approach for sensitive data, and use :session[:variable_name] instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With