Method Common to Several Actions

If one wanted to write a method to be used by several different actions, where would that method be placed? Thanks for any input.

         ... doug

you can put it in application.rb

depending on what the method does, you may instead want to put it in a library, or in a model.

you can put it in application.rb

depending on what the method does, you may instead want to put it in a library, or in a model.

Good suggestions. The thing about application.rb is that I'm thinking that it would be nice if I reserved that for methods that applied to more than one controller. Probably the same philosophy would apply to a library although I could make separate libraries for each controller for which I was providing some sort of special method. That would seem like a good solution. Placing it in a model would also seem like a really good choice. Frankly, I've never understood how one knows exactly what should go into a model. I know that (for whatever reason) I always use a model when I'm connecting to a database or using Action Mailer. Your suggestion of using the model in this case strikes me as a very good one. I just wish I understood exactly WHY it's a good idea. Thanks for the input.

          ... doug

If one wanted to write a method to be used by several different actions, where would that method be placed?

What is the method related to? 1) If it is related to the dispatching/redirection of the actions within a specific controller (rights, authentication, etc), you could use a private method on that controller class. 2) If it is related to the view, how a link should show up/or not, or how a section of the view will be rendered, then you use the helper class for that controller. 3) If it has to do with the business logic surrounding the model related to the action, then add the method to the model class.

My 0.02 anyway.