Browse Source

Make create user let users enter address info, only require phone num

denney-disable-on-select
Jason Denney 12 years ago
parent
commit
6918520b01
  1. 7
      app/models/user.rb
  2. 10
      app/models/user_profile.rb
  3. 24
      app/views/devise/registrations/_user_profile_fields.html.haml
  4. 3
      app/views/devise/registrations/new.html.haml

7
app/models/user.rb

@ -7,17 +7,18 @@ class User < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model # Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, 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 has_many :user_profiles
accepts_nested_attributes_for :user_profiles, allow_destroy: false
belongs_to :user_role belongs_to :user_role
belongs_to :bike belongs_to :bike
validates :first_name, :presence => true validates :first_name, :presence => true
validates :last_name, :presence => true validates :last_name, :presence => true
self.per_page = 15
def to_s def to_s
"#{first_name} #{last_name}" "#{first_name} #{last_name}"
end end

10
app/models/user_profile.rb

@ -6,14 +6,12 @@ class UserProfile < ActiveRecord::Base
belongs_to :user belongs_to :user
belongs_to :bike belongs_to :bike
validates :addrStreet1, :presence => true #validates :addrStreet1 , :presence => true
validates :addrCity, :presence => true #validates :addrCity , :presence => true
validates :addrState, :presence => true #validates :addrState , :presence => true
validates :addrZip, :presence => true #validates :addrZip , :presence => true
validates :phone, :presence => true validates :phone, :presence => true
self.per_page = 15
def to_s def to_s
[addrStreet1, addrStreet2, addrCity, addrState, addrZip, phone].join(" - ") [addrStreet1, addrStreet2, addrCity, addrState, addrZip, phone].join(" - ")
end end

24
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

3
app/views/devise/registrations/new.html.haml

@ -17,6 +17,9 @@
= f.label :email = f.label :email
%br/ %br/
= f.email_field :email = f.email_field :email
%div
= f.fields_for :user_profiles, UserProfile.new do |builder|
= render 'user_profile_fields', f: builder
%div %div
= f.label :password = f.label :password
%br/ %br/

Loading…
Cancel
Save