I have a link_to method in my Rails app:
link_to t('edit'), edit_building_path(@building, :hidden_action => params[:action])
How do I remove hidden_action from url?
Currently url looks like:
http://localhost:3000/buildings/2/edit?hidden_action=new
My issue is that I need to know from which page user is accessing this link_to.
In rails helper, it depends on you
def edit_the_building_url(building, you_want_the_params_or_not)
if you_want_the_params_or_not
edit_building_path(building, :hidden_action => params[:action])
else
edit_building_path(building)
end
end
then in your controller
link_to t('edit'), edit_the_building_url(@building, true)
or
link_to t('edit'), edit_the_building_url(@building, false)
if above doesn't profit you, just
url = url.chomp("?hidden_action=#{params[:action]}")