Render js from another controller

Hi all,

In my GamesController I try to render create_or_update.js that is
stored in the events view dir. Apparently Rails alwayslooks in the
games view dir.

Is there a way I can force Rails to look in the events view dir?

class GamesController < ApplicationController
def create
@event = Game.new(params[:game])
respond_to do |format|
if @event.save
format.js { render :action => ‘…/events/create_or_update’ }
#doesn’t work
end
end
end
end

Thanks

Tarscher wrote:

Hi all,

In my GamesController I try to render create_or_update.js that is
stored in the events view dir. Apparently Rails alwayslooks in the
games view dir.

Is there a way I can force Rails to look in the events view dir?

class GamesController < ApplicationController
def create
@event = Game.new(params[:game])
respond_to do |format|
if @event.save
format.js { render :action => ‘…/events/create_or_update’ }
#doesn’t work
end
end
end
end

Thanks

Excerpt from Rail docs on the render method

Rendering a template

Template rendering works just like action rendering except that it takes
a path relative to the template root. The current layout is
automatically applied.

Renders the template located in

[TEMPLATE_ROOT]/weblog/show.r(html|xml) (in Rails,
app/views/weblog/show.erb)
render :template => “weblog/show”

Renders the template with a local variable

render :template => “weblog/show”, :locals => {:customer =>
Customer.new}

    format.js { render :template => 'events/create_or_update' }

I think this is the right way to do it.

Robert W. wrote:

    format.js { render :template => 'events/create_or_update' }

I think this is the right way to do it.

On second thought maybe that should be
format.js { render :template => ‘events/create_or_update’,
:layout => false }