In Rails, how can you infer the name of an action from within a view?

If I visualize the update action from the create action, is there a way to present the "update" view (for example, update.html.erb) to find out what action it performed. I want the update view to print the name of the "create" action when the create action displays it and print the word "update" when the update action displays it. The rendering problem seems to be delaying control of the action being called, so for all purposes and tasks, the update view always thinks that it comes from the update action.

class CtrlController < ApplicationController

  def create
    render(:action=>"update")
  end

  def read
  end

  def update
  end

  def delete
  end
+3
source share
1

PARAMS [: ]

render :template => "ctrl/update"
+6

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


All Articles