Where should I put a method in Rails that will be used by all of my models?
Active record extensions while server starts
# config/initializers/core_extensions.rb
class ActiveRecord::Base
# write ur common base code here
def self.per_page
@@per_page ||= 10
end
def self.pagination(options)
paginate :per_page => options[:per_page] || per_page, :page => options[:page]
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With