Hey, we like to realize a RoR project with a huge amount of controller code. What is the best way to handle that. Is there a similar mechanism for helper as for views or a way to include/load external code? Otmar Tschendel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060310/789a3fad/attachment.html
Otmar Tschendel wrote:> Hey, > > we like to realize a RoR project with a huge amount of controller code. > What is the best way to handle that. > Is there a similar mechanism for helper as for views or a way to > include/load external code? > > > Otmar Tschendelhi, you could group the code in modules and then include the modules in the controller. -- Agnieszka Figiel -- Posted via http://www.ruby-forum.com/.
You can place non-action methods in module and save that in a file in your lib directory, which you can then include in your controller. Example: lib\extra_methods.rb: module ExtraControllerMethods # ... your code end app\controllers\some_controller.rb: require ''extra_methods'' class SomeController < ApplicationController include ExtraControllerMethods end A better solution, though, would be to refactor portions of your controller into smaller chunks. If you have so much code it''s getting unmanageable, just splitting portions out into another file isn''t going to help much. On 3/10/06, Otmar Tschendel <otmar.tschendel@philips.com> wrote:> > > Hey, > > we like to realize a RoR project with a huge amount of controller code. > What is the best way to handle that. > Is there a similar mechanism for helper as for views or a way to > include/load external code? > > > Otmar Tschendel > > _______________________________________________ > 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/20060310/c8a1fbab/attachment.html
Otmar Tschendel wrote:> we like to realize a RoR project with a huge amount of controller code. > What is the best way to handle that. > Is there a similar mechanism for helper as for views or a way to > include/load external code?You can put "helper" code in files in the /lib directory. You can even make them modules and mix them in to the controller(s). Or you can split your controller into multiple controllers and hide that division using custom routes to map some actions to one controller and others to another. --josh http://blog.hasmanythrough.com -- Posted via http://www.ruby-forum.com/.