Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying a :format in link_to doesn't work in rails 3.2.2

I'm moving a project from rails 3.1 to rails 3.2.2 and I have this:

= link_to 'CSV', :action => 'list', :search => @search, :format => 'csv'

In rails 3.1 this specifies the format in the html link (format=csv) and it is caught by a respond_with, but in 3.2.2 the format never makes it into the link. I scanned through the list of commits on github and can't find anything that relates to this.

Edit:

Looks like this is an issue with url_for

#rails 3.1
url_for :controller=>'posts', :action=>'index', :format=>:xml
/admin/posts/index?format=xml

#rails 3.2.2
url_for :controller=>'posts', :action=>'index', :format=>:xml
/admin/posts/index

#rails 3.2.2
url_for :controller=>'posts', :action=>'index', :format=>:xml, :id => 5
/admin/posts/index/5.xml
like image 836
cbron Avatar asked May 02 '12 19:05

cbron


1 Answers

Try using :format => :csv

http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to#32-Link-to-same-URL-with-different-format

like image 125
Matzi Avatar answered Sep 20 '22 22:09

Matzi