Heya, I want to layout my components like mini-apps, because that''s what they really are. I moved them into components/name/{models,controllers,views,helpers,apis} and that''s all fine once I hacked initializer to load up each component like it. The only issue I have now is I am unable to use ComponentName::ComponentController. And I really want to put my controllers in this fashion, components/name/controllers/name/controller.rb. If I have the controller in components/name/controllers/ and load it i''ll get errors because I use ComponentName::ComponentController < ComponentName::ComponentBaseController. The errors are strange mainly because the base controller does get loaded, but is unable to be found in AS/dependencies.rb(197) const_defined? I tried moving it into the subdirectory, but I then get ComponentName uninitialized constant. I am unsure why this is happening. If anyone has done something similar let me know. Dylan.
Have you looked at Rails Engines? I''m not entirely sure what your components/mini-apps might be, but if they include models then it''s likely that they really aren''t standard Rails Components and might be be not treated as such... http://rails-engines.rubyforge.org/ - james On 11/4/05, Dylan Egan <dylanegan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Heya, > > I want to layout my components like mini-apps, because that''s what they > really are. I moved them into > components/name/{models,controllers,views,helpers,apis} and that''s all > fine once I hacked initializer to load up each component like it. > > The only issue I have now is I am unable to use > ComponentName::ComponentController. And I really want to put my > controllers in this fashion, components/name/controllers/name/controller.rb. > > If I have the controller in components/name/controllers/ and load it > i''ll get errors because I use ComponentName::ComponentController < > ComponentName::ComponentBaseController. The errors are strange mainly > because the base controller does get loaded, but is unable to be found > in AS/dependencies.rb(197) const_defined? > > I tried moving it into the subdirectory, but I then get ComponentName > uninitialized constant. I am unsure why this is happening. > > If anyone has done something similar let me know. > > Dylan. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
How do I choose whether to use a plugin, engine, or a component? Is there any docs I can see describing the process involved in this decision?>From what I gather about Plugins, they work to extend the base functionalityof Rails from the perspective of helpers, modules, and models. But if I have any views and interfacing into that functionality such as in a controller, I should use an engine. Are there any other reasons behind using a engine over a plugin, or visa-versa. Also, what about a component? 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> Have you looked at Rails Engines? I''m not entirely sure what > your components/mini-apps might be, but if they include > models then it''s likely that they really aren''t standard > Rails Components and might be be not treated as such... > > http://rails-engines.rubyforge.org/ > > - james > > On 11/4/05, Dylan Egan <dylanegan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Heya, > > > > I want to layout my components like mini-apps, because that''s what > > they really are. I moved them into > > components/name/{models,controllers,views,helpers,apis} and > that''s all > > fine once I hacked initializer to load up each component like it. > > > > The only issue I have now is I am unable to use > > ComponentName::ComponentController. And I really want to put my > > controllers in this fashion, > components/name/controllers/name/controller.rb. > > > > If I have the controller in components/name/controllers/ > and load it > > i''ll get errors because I use ComponentName::ComponentController < > > ComponentName::ComponentBaseController. The errors are > strange mainly > > because the base controller does get loaded, but is unable > to be found > > in AS/dependencies.rb(197) const_defined? > > > > I tried moving it into the subdirectory, but I then get > ComponentName > > uninitialized constant. I am unsure why this is happening. > > > > If anyone has done something similar let me know. > > > > Dylan.
>From The ''Agile'' book: "Components let us call actions from within aview or another action. The logic of the action will be executed, and its results rendered. These results can be inserted into the output of the current action." In other words, if you have some thing like a shopping cart which you might want to render on many pages within your site, you would package the controllers, helpers and views (probably partials) as a component. A component therefore is the encapsulated code required to display some frequently-needed information within other controllers/views of your application. Plugins are more flexible in that they can contain almost any code - enhancements to ActiveRecord objects (i.e. http://www.kanthak.net/opensource/file_column/), to add new helper methods (http://lesscode.org/svn/rtomayko/rails/plugins/enhanced-form-tag-helper/), and so on. They also have ''boot'' code in the form of an init.rb (often where a plugin will include its enhancements into the Rails Base classes). Plugins would seem to be the choice if you want to add functionality across a whole application (i.e. adding versioning to many/all model objects). Engines use useful when you have an entire ''subsystem'' of a Rails application (such as managing users & permissions) where you have model objects, controllers to manipulate/administer those objects (updating, creating new ones) and a full set of views & helpers to display information about those objects. Engines are like a slice of an application from top (views/helpers) to bottom (models) which can be dropped into an existing application and appear as if they always existing in the normal /app directory. Developers can selectively override parts of Engines as they need to handle their application (such as changing the user/home view to display a silly name, without affecting the rest of the Engine). I hope that helps... without knowing more about what you want your ''components'' to do, I''m not sure which might best suit your needs. - james On 11/4/05, Nathaniel S. H. Brown <nshb-wgYSSEAWXinQT0dZR+AlfA@public.gmane.org> wrote:> How do I choose whether to use a plugin, engine, or a component? Is there > any docs I can see describing the process involved in this decision? > > >From what I gather about Plugins, they work to extend the base functionality > of Rails from the perspective of helpers, modules, and models. But if I have > any views and interfacing into that functionality such as in a controller, I > should use an engine. Are there any other reasons behind using a engine over > a plugin, or visa-versa. > > Also, what about a component? > > 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 > > > > Have you looked at Rails Engines? I''m not entirely sure what > > your components/mini-apps might be, but if they include > > models then it''s likely that they really aren''t standard > > Rails Components and might be be not treated as such... > > > > http://rails-engines.rubyforge.org/ > > > > - james > > > > On 11/4/05, Dylan Egan <dylanegan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Heya, > > > > > > I want to layout my components like mini-apps, because that''s what > > > they really are. I moved them into > > > components/name/{models,controllers,views,helpers,apis} and > > that''s all > > > fine once I hacked initializer to load up each component like it. > > > > > > The only issue I have now is I am unable to use > > > ComponentName::ComponentController. And I really want to put my > > > controllers in this fashion, > > components/name/controllers/name/controller.rb. > > > > > > If I have the controller in components/name/controllers/ > > and load it > > > i''ll get errors because I use ComponentName::ComponentController < > > > ComponentName::ComponentBaseController. The errors are > > strange mainly > > > because the base controller does get loaded, but is unable > > to be found > > > in AS/dependencies.rb(197) const_defined? > > > > > > I tried moving it into the subdirectory, but I then get > > ComponentName > > > uninitialized constant. I am unsure why this is happening. > > > > > > If anyone has done something similar let me know. > > > > > > Dylan. > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >