I have a method in a module which generates a csv file called to_csv.
My controller action:
def download_csv
@rating = RatingSet.find(params[:rating_set_id])
rating_id = @rating.id
respond_to do |format|
format.csv { send_data @rating.to_cvs(rating_id) }
end
end
My route:
download_csv_co_view_rating_index GET /co_view_rating/download_csv(.:format) co_view_rating#download_csv
My view:
<small><%=link_to "Download CSV Data", :controller => "co_view_rating", :action => "download_csv", :rating_set_id => rating.id %></small>
When I click the link, the link will open:
co_view_rating/download_csv?rating_set_id=6
But nothing happens. What am I missing/doing wrong?
You need to pass the format type to your link_to helper:
Update
If you need to include the params as well then do: