Hi, I''m trying to clean up my methods and especially my controllers as they''re getting pretty bloated. Got a question, am I right in thinking that any methods I put into the inididual models are only accesible from their corresponding controllers? With the Helpers, any methods I put in there, can I use them in the views?, looks like I can only use them in the controllers? Want to move some of the methods I''m using for the views outside /controllers/application.rb as it''s getting pretty unmanageable. Any ideas? -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
On 31 Mar 2008, at 16:51, John Griffiths wrote:> > Hi, I''m trying to clean up my methods and especially my controllers as > they''re getting pretty bloated. > > Got a question, am I right in thinking that any methods I put into the > inididual models are only accesible from their corresponding > controllers?No. There isn''t really a strong association between controllers and models. if you''ve got a method on a model class you can call it whenever you have an instance of the class at hand (unless of course you make that method protected/private)> > With the Helpers, any methods I put in there, can I use them in the > views?, looks like I can only use them in the controllers?By default helper methods are only available to views> > Want to move some of the methods I''m using for the views outside > /controllers/application.rb as it''s getting pretty unmanageable.You may find it helps to group related methods in modules and include those in relevant controllers.> > > Any ideas? > -- > 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?hl=en -~----------~----~----~----~------~----~------~--~---
Read this: http://wiki.rubyonrails.org/rails/pages/UnderstandingWhatMethodsGoWhere That said. I have dozens upon dozens of methods I use in globally. Currently, I am in the process of moving those out of application_helper and into subfiles that are included at the top (My app helper was getting huge). That way I can logically organize them, but they are still available everywhere. I hope this helps. H --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---