From 6918520b01154cc32f7976d9c3b94b1bfbb993dd Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Sun, 6 Jan 2013 22:43:40 -0500 Subject: [PATCH] Make create user let users enter address info, only require phone num --- app/models/user.rb | 7 +++--- app/models/user_profile.rb | 10 ++++---- .../_user_profile_fields.html.haml | 24 +++++++++++++++++++ app/views/devise/registrations/new.html.haml | 3 +++ 4 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 app/views/devise/registrations/_user_profile_fields.html.haml diff --git a/app/models/user.rb b/app/models/user.rb index 9caeccc..a656337 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -7,17 +7,18 @@ class User < ActiveRecord::Base # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me, - :first_name, :last_name, :nickname, :user_role_id, :bike_id + :first_name, :last_name, :nickname, :user_role_id, :bike_id, + :user_profiles_attributes has_many :user_profiles + accepts_nested_attributes_for :user_profiles, allow_destroy: false + belongs_to :user_role belongs_to :bike validates :first_name, :presence => true validates :last_name, :presence => true - self.per_page = 15 - def to_s "#{first_name} #{last_name}" end diff --git a/app/models/user_profile.rb b/app/models/user_profile.rb index 4ef323f..a9a569c 100644 --- a/app/models/user_profile.rb +++ b/app/models/user_profile.rb @@ -6,14 +6,12 @@ class UserProfile < ActiveRecord::Base belongs_to :user belongs_to :bike - validates :addrStreet1, :presence => true - validates :addrCity, :presence => true - validates :addrState, :presence => true - validates :addrZip, :presence => true + #validates :addrStreet1 , :presence => true + #validates :addrCity , :presence => true + #validates :addrState , :presence => true + #validates :addrZip , :presence => true validates :phone, :presence => true - self.per_page = 15 - def to_s [addrStreet1, addrStreet2, addrCity, addrState, addrZip, phone].join(" - ") end diff --git a/app/views/devise/registrations/_user_profile_fields.html.haml b/app/views/devise/registrations/_user_profile_fields.html.haml new file mode 100644 index 0000000..45a74b8 --- /dev/null +++ b/app/views/devise/registrations/_user_profile_fields.html.haml @@ -0,0 +1,24 @@ +%fieldset + = f.label :addrStreet1 + %br/ + = f.text_field :addrStreet1 + %br/ + = f.label :addrStreet2 + %br/ + = f.text_field :addrStreet2 + %br/ + = f.label :addrCity + %br/ + = f.text_field :addrCity + %br/ + = f.label :addrState + %br/ + = f.text_field :addrState + %br/ + = f.label :addrZip + %br/ + = f.text_field :addrZip + %br/ + = f.label :phone + %br/ + = f.text_field :phone diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index ef1ec0b..f5b9336 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -17,6 +17,9 @@ = f.label :email %br/ = f.email_field :email + %div + = f.fields_for :user_profiles, UserProfile.new do |builder| + = render 'user_profile_fields', f: builder %div = f.label :password %br/