Hi all We all have seen those great plugins that can simplify your life with just a few (or even a single) lines. They all use the extensible class definition of Rails and such stuff, and it would be a dream to be able to do such plugins yourself. And exactly that is what I''d like to learn. To be a little more precise: I want to create a plugin that extends a controller and a model class with some methods dynamically based on a few configurations by the user. E.g.: I have a controller NewsController and a model News. In the controller I put something like that: class NewsController < ApplicationController hello_world_plugin :my_name # E.g. :josh end Now my plugin should add the following method to NewsController: def hello_world render :action => :my_name # :my_name should be replace with the specified value, e.g. :josh end And it should alos add a method to my News model: def hello_my_sweet_world # Some other stuff end I guess I find out how the architecture of a plugin works (by taking a look at existing plugins), but I''m quite un-experienced in stuff like extending classes and such. What I need are references to tutorials or something like that; I have the PickAxe and Agile 2nd Ed at home... Thank you very much :-) Joshua -- 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 -~----------~----~----~----~------~----~------~--~---
On 9/25/06, Joshua Muheim <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> We all have seen those great plugins that can simplify your life with > just a few (or even a single) lines. They all use the extensible class > definition of Rails and such stuff, and it would be a dream to be able > to do such plugins yourself. > > And exactly that is what I''d like to learn.The hard part of writing a plugin is identifying what to write, not how to write it. Basically identify what is currently difficult in the Rails world, and unsolved by the plugin community so far. Writing the plugin is the easy part. However I have seen some ambivalence to plugins. Some plugins broke with Rails versions, or the plugins themselves weren''t mature enough (features vs testing). Current wisdom seems to be to use plugins sparingly, or thoroughly validate them yourself. Its really no different to any other development - if a problem happens in your application, it is best if it happens in your code and not a library or plugin that you are using. I am not trashing plugin authors here, I am advocating that you do not overlook the necessary steps to mature it (testing, community feedback, more testing, test with different rails versions and then do some testing) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You aren''t going to be extending a controller and a model with just one line in a controller, since controllers aren''t that directly connected to models. For some tips on how to write plugins, though, see the wiki: http://wiki.rubyonrails.com/rails/pages/HowTosPlugins Another way to learn is to look at the excellent plugins written by Rick Olson: http://svn.techno-weenie.net/projects/plugins/ -- Building an e-commerce site with Rails? http://www.agilewebdevelopment.com/rails-ecommerce On Sep 25, 2006, at 6:29 AM, Joshua Muheim wrote:> > Hi all > > We all have seen those great plugins that can simplify your life with > just a few (or even a single) lines. They all use the extensible class > definition of Rails and such stuff, and it would be a dream to be able > to do such plugins yourself.... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If you''ll forgive the outrageous self-promotion, Addison Wesley have recently released a short PDF book which should help guide you though what you can do with Rails plugin: http://www.awprofessional.com/bookstore/product.asp?isbn=0321483510&rl=1 I''ll make a bit more of a noise about this once they fix the typo in my surname :) - James On 9/25/06, Joshua Muheim <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi all > > We all have seen those great plugins that can simplify your life with > just a few (or even a single) lines. They all use the extensible class > definition of Rails and such stuff, and it would be a dream to be able > to do such plugins yourself. > > And exactly that is what I''d like to learn. To be a little more precise: > > I want to create a plugin that extends a controller and a model class > with some methods dynamically based on a few configurations by the user. > > E.g.: > > I have a controller NewsController and a model News. In the controller I > put something like that: > > class NewsController < ApplicationController > hello_world_plugin :my_name # E.g. :josh > end > > Now my plugin should add the following method to NewsController: > > def hello_world > render :action => :my_name # :my_name should be replace with the > specified value, e.g. :josh > end > > And it should alos add a method to my News model: > > def hello_my_sweet_world > # Some other stuff > end > > I guess I find out how the architecture of a plugin works (by taking a > look at existing plugins), but I''m quite un-experienced in stuff like > extending classes and such. What I need are references to tutorials or > something like that; I have the PickAxe and Agile 2nd Ed at home... > > Thank you very much :-) > Joshua > > -- > Posted via http://www.ruby-forum.com/. > > > >-- * J * ~ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---