I have a form_tag in my index page for performing searches on my model.
<%= form_tag( :method => "get", :class => "form-inline") do %>
In the form I have two submit buttons that should direct to two different actions (two different views of displaying the search results.
<div class="btn-group">
<%= submit_tag("View1", :class => 'btn btn btn-success', :name => 'view1') %>
</div>
<div class="btn-group">
<%= submit_tag("View2", :class => 'btn btn btn-primary', :name => 'view2') %>
</div>
When the view1 submit is clicked, I would like to it to point to the view1 action and load that page same as for view 2.
So in my controller I did the following:
def index
if params[:view1]
render :action => 'view1'
elsif params[:view2]
render :action => 'view2'
end
respond_to do |format|
format.html #{ render :layout => false }# index.html.erb
end
end
but when I submit the form it redirects to the save action apparently. The url that is constructed is http://0.0.0.0:3000/posts?class=form-inline&method=get instead of something like http://0.0.0.0:3000/view1?utf8=%E2%9C%93.....
What am I missing here?