Hi, I currently want to extend ActionView to implement custom tags for .rthml files: class ActionView::Base def checkout_link(title = "Proceed to checkout", opts = {}) opts[:href] = url_for(:controller => "store", :action => "checkout") content_tag("a", title, opts) end end this makes my rhtml _very_ readable: <%= checkout_link :color => "red" %> will create a nice and fully featured link, taking extra options into account The above code snippet is currently placed inside app/controllers/application.rb. Unfortunately, in development mode, it is not reloaded like class [ApplicationController] This feels a little like java development - change / restart / checkout *yuk* :-( is there a specific rails location | filename | approach to add this stuff to your rails app and have it reloaded on every request without explicit require(..) or load(..) instructions? Best regards Pete
Nathaniel S. H. Brown
2005-Nov-06 11:50 UTC
RE: extending ActionView with custom tag helper
Although I do not know the answer to this question, you raise something that resonates with me quite deeply. That is to say, I spent a good 4 hours enhancing the file_column plugin and found myself required to stop, then start the web server every time I made a change. Needless to say, this was a serious pain in the development cycle and although I haven''t touched Java, I completely understand where this pain would come from through a required compilation step. With all the hoops already skilfully avoided by using Rails, why make the core framework, especially those of plugin''s, locked in on a reboot? This should at minimum be a configuration option, if not removed in its entirety. As a hosting company, I am finding it a very difficult measure to simply have to reboot my entire apache server, with 30+ clients simply because one client has to change their database config to modify a password, or change the production hostname. Warmest regards, Nathan. -------------------------------------------------------------- Nathaniel S. H. Brown Toll Free 1.877.4.INIMIT Inimit Innovations Phone 604.724.6624 www.inimit.com Fax 604.444.9942> -----Original Message----- > From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Pete > Sent: November 6, 2005 3:42 AM > To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails] extending ActionView with custom tag helper > > Hi, > > I currently want to extend ActionView to implement custom > tags for .rthml > files: > > class ActionView::Base > def checkout_link(title = "Proceed to checkout", opts = {}) > opts[:href] = url_for(:controller => "store", :action => > "checkout") > content_tag("a", title, opts) > end > end > > this makes my rhtml _very_ readable: > > <%= checkout_link :color => "red" %> > > will create a nice and fully featured link, taking extra > options into account > > The above code snippet is currently placed inside > app/controllers/application.rb. > Unfortunately, in development mode, it is not reloaded like > class [ApplicationController] > > This feels a little like java development - change / restart > / checkout > *yuk* :-( > > is there a specific rails location | filename | approach to > add this stuff to your rails app and have it reloaded on > every request without explicit > require(..) or load(..) instructions? > > Best regards > Pete > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hi Pete, Methods like your "checkout_link" are typically placed in a helper such as app/helpers/application_helper.rb Regards, Trevor On 6-Nov-05, at 3:41 AM, Pete wrote:> Hi, > > I currently want to extend ActionView to implement custom tags for > .rthml files: > > class ActionView::Base > def checkout_link(title = "Proceed to checkout", opts = {}) > opts[:href] = url_for(:controller => "store", :action => > "checkout") > content_tag("a", title, opts) > end > end > > this makes my rhtml _very_ readable: > > <%= checkout_link :color => "red" %> > > will create a nice and fully featured link, taking extra options into > account > > The above code snippet is currently placed inside > app/controllers/application.rb. > Unfortunately, in development mode, it is not reloaded like class > [ApplicationController] > > This feels a little like java development - change / restart / > checkout *yuk* :-( > > is there a specific rails location | filename | approach to add this > stuff to > your rails app and have it reloaded on every request without explicit > require(..) or load(..) instructions? > > Best regards > Pete > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Trevor Squires http://somethinglearned.com
Hi Trevor, thanks a billion times !!!! :-) Runs like a charm now and reload nicely :-) Best regards Peter On Sun, 06 Nov 2005 13:01:15 +0100, Trevor Squires <trevor-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote:> Hi Pete, > > Methods like your "checkout_link" are typically placed in a helper such > as app/helpers/application_helper.rb > > Regards, > Trevor > > On 6-Nov-05, at 3:41 AM, Pete wrote: > >> Hi, >> >> I currently want to extend ActionView to implement custom tags for >> .rthml files: >> >> class ActionView::Base >> def checkout_link(title = "Proceed to checkout", opts = {}) >> opts[:href] = url_for(:controller => "store", :action => "checkout") >> content_tag("a", title, opts) >> end >> end >> >> this makes my rhtml _very_ readable: >> >> <%= checkout_link :color => "red" %> >> >> will create a nice and fully featured link, taking extra options into >> account >> >> The above code snippet is currently placed inside >> app/controllers/application.rb. >> Unfortunately, in development mode, it is not reloaded like class >> [ApplicationController] >> >> This feels a little like java development - change / restart / checkout >> *yuk* :-( >> >> is there a specific rails location | filename | approach to add this >> stuff to >> your rails app and have it reloaded on every request without explicit >> require(..) or load(..) instructions? >> >> Best regards >> Pete >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > -- > Trevor Squires > http://somethinglearned.com > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hi Nathan, See below: On 6-Nov-05, at 3:50 AM, Nathaniel S. H. Brown wrote:> Although I do not know the answer to this question, you raise > something that > resonates with me quite deeply. That is to say, I spent a good 4 hours > enhancing the file_column plugin and found myself required to stop, > then > start the web server every time I made a change. > > Needless to say, this was a serious pain in the development cycle and > although I haven''t touched Java, I completely understand where this > pain > would come from through a required compilation step. > > With all the hoops already skilfully avoided by using Rails, why make > the > core framework, especially those of plugin''s, locked in on a reboot? > This > should at minimum be a configuration option, if not removed in its > entirety. >I''m certainly not an expert but I think the reason why the core framework (and plugins, which are, imho, designed as a way to allow developers to *extend* the core framework) is locked in on a reboot is for performance and (perhaps) to avoid memory leaks. You can see the performance impact of reloading the core framework simply by running rails as a straight cgi. As for just reloading plugins - I think it''ll put a rather large burden on the plugin developer to make sure they clean up after themselves on each reload. Something that was opt-in would be ok but I really don''t think it''s a good idea making it a default action.> As a hosting company, I am finding it a very difficult measure to > simply > have to reboot my entire apache server, with 30+ clients simply > because one > client has to change their database config to modify a password, or > change > the production hostname. >Clearly I don''t know your config but I''d assume that each of your 30 clients is running their own instance of rails - do you really need to restart *everyone*? Regards, Trevor> Warmest regards, > Nathan. > > -------------------------------------------------------------- > Nathaniel S. H. Brown Toll Free 1.877.4.INIMIT > Inimit Innovations Phone 604.724.6624 > www.inimit.com Fax 604.444.9942 > > >> -----Original Message----- >> From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Pete >> Sent: November 6, 2005 3:42 AM >> To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> Subject: [Rails] extending ActionView with custom tag helper >> >> Hi, >> >> I currently want to extend ActionView to implement custom >> tags for .rthml >> files: >> >> class ActionView::Base >> def checkout_link(title = "Proceed to checkout", opts = {}) >> opts[:href] = url_for(:controller => "store", :action => >> "checkout") >> content_tag("a", title, opts) >> end >> end >> >> this makes my rhtml _very_ readable: >> >> <%= checkout_link :color => "red" %> >> >> will create a nice and fully featured link, taking extra >> options into account >> >> The above code snippet is currently placed inside >> app/controllers/application.rb. >> Unfortunately, in development mode, it is not reloaded like >> class [ApplicationController] >> >> This feels a little like java development - change / restart >> / checkout >> *yuk* :-( >> >> is there a specific rails location | filename | approach to >> add this stuff to your rails app and have it reloaded on >> every request without explicit >> require(..) or load(..) instructions? >> >> Best regards >> Pete >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Trevor Squires http://somethinglearned.com
On 6 Nov 2005, at 06:41, Pete wrote:> This feels a little like java development - change / restart / > checkout *yuk* :-(Let me just nip this fallacy in the bud right now.... only if you are coding Java using a non-modern environment would you have such pain. Using Eclipse, for example, only requires saving the file to have a running system refreshed provided the project is configured properly. Many Java developers work this way, so the Rails change- and-refresh selling point isn''t what pulls us old Java folks to Rails... but rather the amount and inelegance of the "changes" needed before refreshing :) Erik
Everyone says that but I don''t see any blog/article about what it means to have "project is configured properly." -=- Neeraj On 11/6/05, Erik Hatcher <erik-LIifS8st6VgJvtFkdXX2HpqQE7yCjDx5@public.gmane.org> wrote:> > > On 6 Nov 2005, at 06:41, Pete wrote: > > This feels a little like java development - change / restart / > > checkout *yuk* :-( > > Let me just nip this fallacy in the bud right now.... only if you are > coding Java using a non-modern environment would you have such pain. > Using Eclipse, for example, only requires saving the file to have a > running system refreshed provided the project is configured > properly. Many Java developers work this way, so the Rails change- > and-refresh selling point isn''t what pulls us old Java folks to > Rails... but rather the amount and inelegance of the "changes" needed > before refreshing :) > > Erik > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 6 Nov 2005, at 10:34, Neeraj Kumar wrote:> Everyone says that but I don''t see any blog/article about what it > means to have "project is configured properly."First, apologies for the OT post - I just want to be sure that at least the reasons folks rant about Java is accurate :) It really all depends on the type of project. Most of the code I write in Java is standalone code that doesn''t require an application server to run in, so there is no additional configuration necessary in this case. Eclipse compiles behind the scenes automatically, and simply re-running a test case, or running a main program is very quick after a change of code. In cases where an application server is needed, there is additional configuration to have Tomcat or other containers mapped in such that classes end up in the right spot and the container is configured for reloading. I''m certain there are many articles and blog entries detailing Eclipse configuration. Erik> > -=- Neeraj > > On 11/6/05, Erik Hatcher <erik-LIifS8st6VgJvtFkdXX2HpqQE7yCjDx5@public.gmane.org> wrote: > On 6 Nov 2005, at 06:41, Pete wrote: > > This feels a little like java development - change / restart / > > checkout *yuk* :-( > > Let me just nip this fallacy in the bud right now.... only if you are > coding Java using a non-modern environment would you have such pain. > Using Eclipse, for example, only requires saving the file to have a > running system refreshed provided the project is configured > properly. Many Java developers work this way, so the Rails change- > and-refresh selling point isn''t what pulls us old Java folks to > Rails... but rather the amount and inelegance of the "changes" needed > before refreshing :) > > Erik > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hi Erik, sorry if I got something wrong, but... java: only partial class-reloading on method implementation changes (if at all) through Java HotSwap(tm) changes to the signature of the class or add/remove of classes are not handled --> http://java.sun.com/j2se/1.4.2/docs/guide/jpda/enhancements.html ruby: full reload possible using load(..) instead of require(..) the presence of Eclipse won''t remove the lack of java to have fully dynamic reloading... that''s what I meant with [restart] the "fastest" environment I got in java was jetty and tapestry 3 using eclipse 3.1 sdk The development cycle still sucks big time compared to rails... java: change a tiny piece - restart/reload web application, usually 10-20 seconds, even on fast machine - click through browser back to back I wanted to test Thank to god for having rails :-))) On Sun, 06 Nov 2005 16:15:20 +0100, Erik Hatcher <erik-LIifS8st6VgJvtFkdXX2HpqQE7yCjDx5@public.gmane.org> wrote:> > On 6 Nov 2005, at 06:41, Pete wrote: >> This feels a little like java development - change / restart / checkout >> *yuk* :-( > > Let me just nip this fallacy in the bud right now.... only if you are > coding Java using a non-modern environment would you have such pain. > Using Eclipse, for example, only requires saving the file to have a > running system refreshed provided the project is configured properly. > Many Java developers work this way, so the Rails change-and-refresh > selling point isn''t what pulls us old Java folks to Rails... but rather > the amount and inelegance of the "changes" needed before refreshing :) > > Erik > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Nathaniel S. H. Brown
2005-Nov-06 20:47 UTC
RE: extending ActionView with custom tag helper
> On 6-Nov-05, at 3:50 AM, Nathaniel S. H. Brown wrote: > > > Although I do not know the answer to this question, you raise > > something that resonates with me quite deeply. That is to > say, I spent > > a good 4 hours enhancing the file_column plugin and found myself > > required to stop, then start the web server every time I made a > > change. > > > > Needless to say, this was a serious pain in the development > cycle and > > although I haven''t touched Java, I completely understand where this > > pain would come from through a required compilation step. > > > > With all the hoops already skilfully avoided by using > Rails, why make > > the core framework, especially those of plugin''s, locked in on a > > reboot? > > This > > should at minimum be a configuration option, if not removed in its > > entirety. > > > > I''m certainly not an expert but I think the reason why the > core framework (and plugins, which are, imho, designed as a > way to allow developers to *extend* the core framework) is > locked in on a reboot is for performance and (perhaps) to > avoid memory leaks. > > You can see the performance impact of reloading the core > framework simply by running rails as a straight cgi. >I will test this out with CGI. I wasn''t aware that the CGI architecture reloaded this ever time. One idea then, would be to setup the script to test which environment the site is in. If it is running the development instance, to use the CGI, but if in production, to use the FCGI and cache the core into memory.> As for just reloading plugin''s - I think it''ll put a rather > large burden on the plugin developer to make sure they clean > up after themselves on each reload. Something that was > opt-in would be ok but I really don''t think it''s a good idea > making it a default action. >Making this a configuration option would be excellent. I could then put this in the ./config/environments/development.rb and sacrifice the chance of memory leaks and slow performance over simplicity and ease of modifying the plugin and core.> > As a hosting company, I am finding it a very difficult measure to > > simply have to reboot my entire apache server, with 30+ > clients simply > > because one client has to change their database config to modify a > > password, or change the production hostname. > > > > Clearly I don''t know your config but I''d assume that each of > your 30 clients is running their own instance of rails - do > you really need to restart *everyone*? >Currently, actually all of my clients are running PHP at the moment. I am working at learning Rails to be able to offer solutions to them. With the current setup involving Plesk as the Web Hosting management agent, there is only one instance of Apache running on the server, and I have each client setup on virtual hosts. Presently I have about 4 sites which I am running the FCGI with, http://wiki.vanruby.com, http://talks.inimit.com, and a couple others. I realize most of the hard core guys use the command line to manage their clients, but I am really in need of simplifying this into a interface. If Plesk is unable to manage many clients efficiently with Rails on FCGI, as I am finding, what other control panels do? Does cPanel by chance? Warmest regards, Nathan. -------------------------------------------------------------- Nathaniel S. H. Brown Toll Free 1.877.4.INIMIT Inimit Innovations Phone 604.724.6624 www.inimit.com Fax 604.444.9942
On 6 Nov 2005, at 12:03, Pete wrote:> Hi Erik, > > sorry if I got something wrong, but... > > java: only partial class-reloading on method implementation changes > (if at all) through Java HotSwap(tm) > changes to the signature of the class or add/remove of > classes are not handled > --> http://java.sun.com/j2se/1.4.2/docs/guide/jpda/ > enhancements.html > > ruby: full reload possible using load(..) instead of require(..) > > the presence of Eclipse won''t remove the lack of java to have fully > dynamic reloading...Eclipse is leveraging more than just HotSwap. It surely plays games with classloaders and such. It most definitely works fine to reload classes.> the "fastest" environment I got in java was jetty and tapestry 3 > using eclipse 3.1 sdk > > The development cycle still sucks big time compared to rails...No argument there for web tier applications. I do a fair bit more (middle-tier Lucene based search services for example) that suit Java well. I''m pragmatic like that.> > java: change a tiny piece - restart/reload web application, usually > 10-20 seconds, > even on fast machine - click through browser back to back I wanted > to testJetty is likely the culprit for you. It does not support class reloading. Tomcat would give you much better reload times as the container wouldn''t need to be restarted.> Thank to god for having rails :-)))DHH is cool and all, but let''s not get carried away ;) Erik