views:

1670

answers:

1

I am in one action on Rails, but I wish to continue processing from within another action. My code looks like this:

  send(new_action)                #call the new_action method
  action_name = new_action        #change the controller.action_name
  render :action => new_action    #inform the view that we're in new_action

this works, but the action_name -- though it changes from within the ActionController instance -- is reset when it's retrieved from within the view as

controller.action_name

is there any way to set it and make it stick?

Edit: I have found another solution which doesn't involve this problem, which is here. Thanks!

+4  A: 

You are doing it the wrong way!

That sort of fiddling around in the innards of ActionPack is almost guaranteed to cause you grief sooner or later. There's no guarantee that those internals won't change radically between releases, it's hard to maintain (for yourself and others) as you forget exactly what it's doing and why, and there's the very real possibility of introducing subtle bugs.

Instead, take the code that's common to both actions and put it into a common method, like a private method in the controller, more logic in the models, or, if necessary, a common function higher in the inheritance chain of the controllers.

womble
thanks. I've decided to go a different way with my solution to the problem, which is now here http://stackoverflow.com/questions/230335//491609#491609
Yar