views:

32

answers:

1

I would like to create a link that pass a parameter, so I don't have to ask it in the form.

Something like this :

<%= button_to "New", new_skill_path(:controller => "skills",:action => "new", :request => "true") %>

I can show that the parameter is taken… but on my view, The <%= f.text_field :request %> is not "true" ?

(idem if I add :post)

+1  A: 

Try to don't use @request because Rails Use the request method, and I prefer to use link_to instead of button_to, anyway you will send your data by get method.

Views

<%= link_to("New", "/skills/new?val=true")  %>

or ...... I think this one is much better

<%= link_to "New",new_skill_path+"?val=true" %>

Controller

@val = true if params[:val] == "true"
Amer
This seems slightly less DRY than it should be because if the route to the skills controller is changed you'll have to manually change the specified path in the `link_to` call. How can we leverage the path helpers already available?
Kaleb Pederson