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
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?
My 0.02 anyway.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs