Can I return a value instead of a view from my controller?

I want to return the id of the newly created object for my ajax call, instead of returning the view associated with the controller method.

+4
source share
2 answers

You can do

render :text => @your_object.id 

and then apply responseText to the integer in the javascript handler if necessary.

+9
source

Yes, you can.

 render :text=> "the text that you want to return" 
+1
source

Source: https://habr.com/ru/post/1305828/


All Articles