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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -