Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails - How to add a format to an url helper?

how can I make an URL helper create an URL in a given request/response format?

For example, in my test I have the following:

get(activity_url(activity)) 

This will returns me an HTML on the @response object. I'm looking to have the same behavior of the following:

get({controller: 'activities', action: 'show', id: activity.id, format: 'js'}) 

but without all this wording. Is it possible?

like image 653
fotanus Avatar asked May 22 '13 20:05

fotanus


1 Answers

You should be able to do something like this:

some_resource_path(format: :json) 

or

some_resource_url(format: :xml) 
like image 169
Marek Takac Avatar answered Oct 06 '22 07:10

Marek Takac