views:

224

answers:

2

Hi,

I have a list view in my RoR web app. The view is a result of a scaffold operation.

I want to add a button that will refresh the page. I prefer not to use javascript for this one, is there another way?

Creating a button via button_to or form_tag ends up adding a new blank row in the database when it is clicked.

Thanks! Shay.

+1  A: 

I am going to assume that you are using standard RESTful routes and as a result your form/button_to calls are POSTing to you controller and therefor executing your create action. If that is the case then either of the options you tried should work, just make sure you are setting the method to get so the request is routed to the index action correctly

<%= button_to "Refresh, my_path, :method => :get %>
Peer Allan
+1  A: 

1) Use a link and dress it up as a button w/ CSS

or

2) Use a form whose method is "get", points to the current page (without any params) as the action and has only one element, a submit button?

zackola