Browse Source

Registration form now remembers field values for nested form errors

eperez-timeinput
Jason Denney 12 years ago
parent
commit
2e08f655ea
  1. 13
      app/models/user_profile.rb
  2. 3
      app/views/devise/registrations/new.html.haml

13
app/models/user_profile.rb

@ -1,16 +1,15 @@
class UserProfile < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
attr_accessible :user_id, :addrStreet1, :addrStreet2, :addrCity,
:addrState, :addrZip, :phone
belongs_to :user
belongs_to :bike
#validates :addrStreet1 , :presence => true
#validates :addrCity , :presence => true
#validates :addrState , :presence => true
#validates :addrZip , :presence => true
validates :phone, :presence => true
#validates :addrStreet1 , :presence => true
#validates :addrCity , :presence => true
#validates :addrState , :presence => true
#validates :addrZip , :presence => true
#validates :phone, :presence => true
def to_s
[addrStreet1, addrStreet2, addrCity, addrState, addrZip, phone].join(" - ")

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

@ -18,7 +18,8 @@
%br/
= f.email_field :email
%div
= f.fields_for :user_profiles, UserProfile.new do |builder|
- profile_builder = resource.user_profiles.empty? ? resource.user_profiles.build : resource.user_profiles
= f.fields_for :user_profiles, profile_builder do |builder|
= render 'user_profile_fields', f: builder
%div
= f.label :password

Loading…
Cancel
Save