Browse Source

Registration form now remembers field values for nested form errors

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

3
app/models/user_profile.rb

@ -1,5 +1,4 @@
class UserProfile < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
attr_accessible :user_id, :addrStreet1, :addrStreet2, :addrCity,
:addrState, :addrZip, :phone
@ -10,7 +9,7 @@ class UserProfile < ActiveRecord::Base
#validates :addrCity , :presence => true
#validates :addrState , :presence => true
#validates :addrZip , :presence => true
validates :phone, :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