Showing another controllers action

If I am in controller A and I want to show the index of controller B,
how would I do that?

Wouldn't you just do a simple redirect?

  def create
    @scenario = Scenario.new(params[:scenario])
    if @scenario.save
      flash[:notice] = 'Scenario was successfully created.'
      # where do we return to?
      case params[:from_type]
        when 'project'
          redirect_to projectview_path(params[:from_id])
        else
          redirect_to scenarioviews_path
      end
    else
      render :action => "new"
    end
  end

Ar Chron wrote:

Wouldn't you just do a simple redirect?

  def create
    @scenario = Scenario.new(params[:scenario])
    if @scenario.save
      flash[:notice] = 'Scenario was successfully created.'
      # where do we return to?
      case params[:from_type]
        when 'project'
          redirect_to projectview_path(params[:from_id])
        else
          redirect_to scenarioviews_path
      end
    else
      render :action => "new"
    end
  end

No, I dont want to redirect to another controller. I want to stay in my
current controller.

Here is what I did:

The RJS file replaces my content area with a partial.
My partial uses one line of code

<%= render_file "CONTROLLER_B_NAME/index.html.erb" %>

If anybody else knows a better why, I'd be appreciative to hear it.

In controller A:

render :controller_b, :action => "your_action"

Phil wrote:

In controller A:

render :controller_b, :action => "your_action"

> redirect_to projectview_path(params[:from_id])

Po

sted viahttp://www.ruby-forum.com/.

That doesnt work at all...

I believe it's:

render(:controller => "controller_name", :action => "your_action")

I haven't tried it, but that's the syntax for redirect_to

HTH.

greenideas wrote:

render :template => "foo/bar"