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.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---