Use render instead of redirect if registration/create fails

This commit is contained in:
Ancor Gonzalez Sosa 2013-07-16 16:03:36 +02:00
parent 243f33ff91
commit bae0be338a
5 changed files with 53 additions and 42 deletions

View file

@ -4,6 +4,7 @@ class Person < ActiveRecord::Base
attr_accessible :email, :first_name, :last_name, :public_name, :biography, :company, :avatar, :irc_nickname
belongs_to :user, :inverse_of => :person
has_many :event_people, :dependent => :destroy
has_many :events, :through => :event_people, :uniq => true
has_many :registrations, :dependent => :destroy

View file

@ -1,7 +1,13 @@
class SupporterRegistration < ActiveRecord::Base
belongs_to :supporter_level
belongs_to :registration
before_save :set_attributes_from_person
attr_accessible :registration, :supporter_level_id, :name, :email, :supporter_level, :code, :code_is_valid, :conference_id
def set_attributes_from_person
self.name ||= registration.try(:person).try(:public_name)
self.email ||= registration.try(:person).try(:email)
true
end
end

View file

@ -8,7 +8,7 @@ class User < ActiveRecord::Base
:confirmable
has_and_belongs_to_many :roles
has_one :person
has_one :person, :inverse_of => :user
attr_accessible :email, :password, :password_confirmation, :remember_me, :role_id, :role_ids, :person_attributes
accepts_nested_attributes_for :person
@ -50,7 +50,7 @@ class User < ActiveRecord::Base
private
def create_person
# TODO Search people for existing email address, add to their account
build_person(:email => self.email)
build_person(:email => self.email) if person.nil?
true
end
end