![]() | form_for for a has_one relation model |
|
04 Nov 2012, 23:28
Jean Osorio (1 post) |
I’m new in rails and I have the following question: I have two model user and user_informacion: class User < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation
has_one :user_information
has_secure_password
before_save { |user| user.email = email.downcase }
before_save :create_remember_token
VALID_EMAIL_REGEX = /\A[\w+\
end class UserInformation < ActiveRecord::Base
belongs_to :user
attr_accessible :address, :address2, :business, :descripcion, :identification_number, :mobile_cell, :name, :phone_number
validates :address, presence: true, length: { :maximum => 250 }
validates :address2, length: { :maximum => 250 }
validates :descripcion, presence: true, length: { :maximum => 300 }
validates :identification_number, presence: true
validates :phone_number, presence: true, length: { :is => 11 }
validates :mobile_cell, :length => { :is => 11 }
validates :user_id, presence: true My routes are like this: resources :users do member do resource :user_information end end resources :sessions, only: [:new, :create, :destroy] resources :password_resets
|
| You must be logged in to comment |

