Answers for "rails scope alias"

0

rails scope alias

class User < ActiveRecord::Base
  scope :with_zipcode, lambda { |zip| where(zipcode: zip) }
  singleton_class.send(:alias_method, :has_zipcode, :with_zipcode)
end
Posted by: Guest on June-18-2021

Browse Popular Code Answers by Language