Ruby on Rails: how can I use redirect_to in link_to?

I want to redirect to a specific page after the action (processed by a gemstone) is completed.

+3
source share
2 answers

Redirects are processed in the controller.

Example:

def update
  @model.save
  redirect_to model_path(@model)
end
+1
source

You can do this in three ways.

1) using render: action

def update @ model.save render: action => "page_name" end here it will display you on the page "page_name"

2) render: template => "page_name" here it will display you on the page "page_name"

3) using redirect_to

0
source

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


All Articles