开发者

Ruby on Rails: How can I use a redirect_to in a link_to?

开发者 https://www.devze.com 2023-01-07 05:24 出处:网络
I want to redirect to a certain page after an action (handled by a开发者_运维技巧 gem) is finished.Redirects are handled in the controller.

I want to redirect to a certain page after an action (handled by a开发者_运维技巧 gem) is finished.


Redirects are handled in the controller.

Example:

def update
  @model.save
  redirect_to model_path(@model)
end


you can do this in 3 ways

1) using render :action

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

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

3) using redirect_to

0

精彩评论

暂无评论...
验证码 换一张
取 消