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 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 > > ThanksExcerpt 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Robert Walker 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 } -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---