Hello All, I''m enjoying the simplicity and power of RJS templates in Rails 1.1, but am perplexed about sharing them. I have several templates that I would like to access in various controllers, but if I moved them to views/shared/whatever.rjs, my app can''t seem to find them. I changed the name to _whatever.rjs and referenced them as "shared/whatever", but no luck. Am I missing something? Or is it not possible to share them? It seems like it should be simple, and it would conform with DRY. Actually, now that I''ve typed that out, it sorta makes sense that they can''t be shared like that, since they aren''t partials. So, maybe the broader question is "How do I go about reusing RJS Templates throughout my application?" Regards, -Ron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060428/d755828c/attachment-0001.html
Ron, You renamed it to _whatever.rjs, but when you do: render :action => ''shared/whatever'' Rails will look for whatever.rjs and not _whatever.rjs. On 4/28/06, Ron Miles <ronald.miles@gmail.com> wrote:> Hello All, > > I''m enjoying the simplicity and power of RJS templates in Rails 1.1, but am > perplexed about sharing them. I have several templates that I would like to > access in various controllers, but if I moved them to > views/shared/whatever.rjs, my app can''t seem to find them. I changed the > name to _whatever.rjs and referenced them as "shared/whatever", but no > luck. > > Am I missing something? Or is it not possible to share them? It seems like > it should be simple, and it would conform with DRY. > > Actually, now that I''ve typed that out, it sorta makes sense that they can''t > be shared like that, since they aren''t partials. So, maybe the broader > question is "How do I go about reusing RJS Templates throughout my > application?" > > Regards, > > -Ron > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Cody Fauser http://www.codyfauser.com
Ahhhhhhh, since it''s not a partial, no underscore. Well, no. I must be doing something wrong still. Actual code: <%= link_to_remote( image_tag("capsule_public.gif", :size => "72x16"), :url => { :action => ''shared/script_status_cycle'', :id => @member.id }) Should go to "shared/_script_status.cycle.rjs," I would think. Or "shared/script_cycle_rjs." Neither seem to work. I get this error: ActionController::UnknownAction (No action responded to shared/script_status_cycle), which tells me that it''s not actually the RJS that is the problem, it''s the action. So I think my approach must be wrong. I need to go to the "script_status_cycle" method in my controller, then move to a shared component rather than one in the normal place. I think I''m over-thinking this, or missing something obvious. To clarify after all that, I have an rjs template I want to use in 3 controllers. How do I accomplish that without having to keep 3 copies of the template? Thanks, -Ron On 4/28/06, Cody Fauser <codyfauser@gmail.com> wrote:> Ron, > > You renamed it to _whatever.rjs, but when you do: > > render :action => ''shared/whatever'' > > Rails will look for whatever.rjs and not _whatever.rjs. > > On 4/28/06, Ron Miles <ronald.miles@gmail.com> wrote: > > Hello All, > > > > I''m enjoying the simplicity and power of RJS templates in Rails 1.1, but am > > perplexed about sharing them. I have several templates that I would like to > > access in various controllers, but if I moved them to > > views/shared/whatever.rjs, my app can''t seem to find them. I changed the > > name to _whatever.rjs and referenced them as "shared/whatever", but no > > luck. > > > > Am I missing something? Or is it not possible to share them? It seems like > > it should be simple, and it would conform with DRY. > > > > Actually, now that I''ve typed that out, it sorta makes sense that they can''t > > be shared like that, since they aren''t partials. So, maybe the broader > > question is "How do I go about reusing RJS Templates throughout my > > application?" > > > > Regards, > > > > -Ron > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > Cody Fauser > http://www.codyfauser.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ron Miles ronald.miles@gmail.com 413.329.4277
"Ron Miles" <ronald.miles@gmail.com> writes:> Ahhhhhhh, since it''s not a partial, no underscore. Well, no. I must > be doing something wrong still. Actual code: > > <%= link_to_remote( image_tag("capsule_public.gif", :size => "72x16"), > :url => { :action => ''shared/script_status_cycle'', :id => @member.id })I think your approach is wrong, you need to revise the chapter on ActionPack. It should be something like <%= link_to_remote( image_tag("capsule_public.gif", :size => "72x16"), :url => { :controller => ''my_controller'', :action => ''script_status_cycle'', :id => @member.id }) And then in my_controller define def script_status_cycle blah...blah..code render ''./shared/script_status_cycle'' end should do. I think the above render should work, in case it doesn''t try: render :template => ''./shared/script_status_cycle''> I need to go to the "script_status_cycle" method in my controller, > then move to a shared component rather than one in the normal place. >HTH. -- Surendra Singhi http://ssinghi.kreeti.com, http://www.kreeti.com Read my blog at: http://cuttingtheredtape.blogspot.com/ ,---- | "O thou my friend! The prosperity of Crime is like unto the lightning, | whose traitorous brilliancies embellish the atmosphere but for an | instant, in order to hurl into death''s very depths the luckless one | they have dazzled." -- Marquis de Sade `----
Ron, did you figure this out ? Don''t have time to dig into it... but it seems that being able to share RJS templates is not an option. On 4/28/06, Surendra Singhi <efuzzyone@netscape.net> wrote:> > "Ron Miles" <ronald.miles@gmail.com> writes: > > > Ahhhhhhh, since it''s not a partial, no underscore. Well, no. I must > > be doing something wrong still. Actual code: > > > > <%= link_to_remote( image_tag("capsule_public.gif", :size => > "72x16"), > > :url => { :action => ''shared/script_status_cycle'', :id => > @member.id }) > > I think your approach is wrong, you need to revise the chapter on > ActionPack. > It should be something like > <%= link_to_remote( image_tag("capsule_public.gif", :size => > "72x16"), > :url => { :controller => ''my_controller'', :action => > ''script_status_cycle'', :id => @member.id }) > > And then in my_controller define > > def script_status_cycle > blah...blah..code > render ''./shared/script_status_cycle'' > end > > should do. > I think the above render should work, in case it doesn''t try: > render :template => ''./shared/script_status_cycle'' > > > I need to go to the "script_status_cycle" method in my controller, > > then move to a shared component rather than one in the normal place. > > > > HTH. > -- > Surendra Singhi > http://ssinghi.kreeti.com, http://www.kreeti.com > Read my blog at: http://cuttingtheredtape.blogspot.com/ > ,---- > | "O thou my friend! The prosperity of Crime is like unto the lightning, > | whose traitorous brilliancies embellish the atmosphere but for an > | instant, in order to hurl into death''s very depths the luckless one > | they have dazzled." -- Marquis de Sade > `---- > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060510/3e8b4547/attachment.html
On 28/04/06, Ron Miles <ronald.miles@gmail.com> wrote:> Ahhhhhhh, since it''s not a partial, no underscore. Well, no. I must > be doing something wrong still. Actual code: > > <%= link_to_remote( image_tag("capsule_public.gif", :size => "72x16"), > :url => { :action => ''shared/script_status_cycle'', :id => @member.id }) > > Should go to "shared/_script_status.cycle.rjs," I would think. Or > "shared/script_cycle_rjs." Neither seem to work. > > I get this error: > > ActionController::UnknownAction (No action responded to > shared/script_status_cycle), which tells me that it''s not actually the > RJS that is the problem, it''s the action. So I think my approach must > be wrong.Hi Ron, the following works for me: my_controller.rb (excerpt) ----------------------------------- def do_what_you_have_to_do return render "shared/do_what_you_have_to_do.rjs" end Cheers, Marco
Good evening, The June/2006 issue of ''Dr. Dobb''s Journal'' has, as the cover article, "Ruby On Rails Java''s Successor?". The article starts on page 20. In addition, on page 38, the book "Agile Web Development with Rails" was awarded a Jolt Award. On page 39, MySQL 5.0 was also given a Jolt Award. Finally, for Web Development Tools, Rails 1.0 was given a Jolt Award. It looks like you guys are on to something. Ciao, Pat -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060510/d811f079/attachment-0001.html
Hi Ron Ahhhhhhh, since it''s not a partial, no underscore. Well, no. I must be doing something wrong still. Actual code: <%= link_to_remote( image_tag("capsule_public.gif" , :size => "72x16"), :url => { :action => ''shared/script_status_cycle'', :id => @ member.id }) Should go to "shared/_script_status.cycle.rjs," I would think. Or "shared/script_cycle_rjs." Neither seem to work. In the first example you have an _ at the front again. in the second, your not calling the correct file. script_cycle.rjs instead of script_status_cycle.rjs On 5/11/06, Marco Lazzeri <marco.lazzeri@gmail.com> wrote:> > On 28/04/06, Ron Miles <ronald.miles@gmail.com> wrote: > > Ahhhhhhh, since it''s not a partial, no underscore. Well, no. I must > > be doing something wrong still. Actual code: > > > > <%= link_to_remote( image_tag("capsule_public.gif", :size => > "72x16"), > > :url => { :action => ''shared/script_status_cycle'', :id > => @member.id }) > > > > Should go to "shared/_script_status.cycle.rjs," I would think. Or > > "shared/script_cycle_rjs." Neither seem to work. > > > > I get this error: > > > > ActionController::UnknownAction (No action responded to > > shared/script_status_cycle), which tells me that it''s not actually the > > RJS that is the problem, it''s the action. So I think my approach must > > be wrong. > > Hi Ron, > > the following works for me: > > my_controller.rb (excerpt) > ----------------------------------- > def do_what_you_have_to_do > return render "shared/do_what_you_have_to_do.rjs" > end > > Cheers, > Marco > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060510/d32c2824/attachment.html
Pat Lynch wrote:> Good evening, > > > > The June/2006 issue of ?Dr. Dobb?s Journal? has, as the cover article, > ?Ruby On Rails Java?s Successor??. > > The article starts on page 20. > > > > In addition, on page 38, the book ?Agile Web Development with Rails? was > awarded a Jolt Award. > > > > On page 39, MySQL 5.0 was also given a Jolt Award. > > > > Finally, for Web Development Tools, Rails 1.0 was given a Jolt Award. > > > > It looks like you guys are on to something.Pat, that''s interesting news that deserves being published in its own thread, with a relevant subject line. regards Justin
Hi, I''ll create the thread, if someone will tell me how to do it. Good weekend -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Justin Forder Sent: Thursday, May 11, 2006 1:23 PM To: rails@lists.rubyonrails.org Subject: Re: [Rails] Re: Sharing RJS Templates Pat Lynch wrote:> Good evening, > > > > The June/2006 issue of ''Dr. Dobb''s Journal'' has, as the cover article,> "Ruby On Rails Java''s Successor?". > > The article starts on page 20. > > > > In addition, on page 38, the book "Agile Web Development with Rails"was> awarded a Jolt Award. > > > > On page 39, MySQL 5.0 was also given a Jolt Award. > > > > Finally, for Web Development Tools, Rails 1.0 was given a Jolt Award. > > > > It looks like you guys are on to something.Pat, that''s interesting news that deserves being published in its own thread, with a relevant subject line. regards Justin _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hi, I started a new thread for this... Cheers -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Justin Forder Sent: Thursday, May 11, 2006 1:23 PM To: rails@lists.rubyonrails.org Subject: Re: [Rails] Re: Sharing RJS Templates Pat Lynch wrote:> Good evening, > > > > The June/2006 issue of ''Dr. Dobb''s Journal'' has, as the cover article,> "Ruby On Rails Java''s Successor?". > > The article starts on page 20. > > > > In addition, on page 38, the book "Agile Web Development with Rails"was> awarded a Jolt Award. > > > > On page 39, MySQL 5.0 was also given a Jolt Award. > > > > Finally, for Web Development Tools, Rails 1.0 was given a Jolt Award. > > > > It looks like you guys are on to something.Pat, that''s interesting news that deserves being published in its own thread, with a relevant subject line. regards Justin _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails