I create a simple module in ruby to implement on ActiveRecord model.
module Parameterize
def to_param
"#{ id } #{ name }".parameterize
end
end
The question it's where to place the file?
- app/models
- config/initializers
- lib
- other
I create a simple module in ruby to implement on ActiveRecord model.
module Parameterize
def to_param
"#{ id } #{ name }".parameterize
end
end
The question it's where to place the file?
These generally are placed in a new directory off app
called concerns
- it's worth googling for more info about how that works.
here's a good ref of places to go look: How to use concerns in Rails 4