0

my question is: I need to access one action after another Controller action is accessed, completed and rendered and the second reason action will have another rendering. Observers thought to use, but from what I read they deal only with Models.

def action_1

 render :xml => {:success => "Msg success."}

end

def action_2

 render :nothing => "", :locals => {:scheduling_id => scheduling_id}

end

4

1 回答 1

0

“动作”只是方法调用。 action_1可以调用action_2但你不能调用render不止一次,所以你有一个需要处理的结构问题。

也许这样的事情就是你想要的?

class MyController < ApplicationController

  def my_action
    # ...
    my_shared_stuff
    render ...
  end

  private

  def my_shared_stuff
    # ... shared things
  end

end
于 2013-08-23T13:46:34.637 回答