Ruby on rails access to model information to an another model -
i have first model contact field :email , need same field :email in model customer value of field :email in model contact.
i use mongoid orm here's first model contact
class contact include mongoid::document include mongoid::timestamps embedded_in :customer embedded_in :employee embedded_in :restaurant field :city field :street field :zip_code field :country field :phone_number field :email and second model customer
class customer include mongoid::document include mongoid::timestamps embeds_one :contact devise :database_authenticatable, :lockable, :recoverable, :rememberable, :registerable, :trackable, :timeoutable, :validatable, :token_authenticatable attr_accessible :email, :password, :password_confirmation field :first_name field :last_name field :password field :gender field :encrypted_password thanks.
if using activesupport, delegate should job.
in customer.rb
delegate :email, :to => :contact
Comments
Post a Comment