Skip to content

Instantly share code, notes, and snippets.

@tensiondriven
Created July 2, 2012 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tensiondriven/3036025 to your computer and use it in GitHub Desktop.
Save tensiondriven/3036025 to your computer and use it in GitHub Desktop.
logs
Loading production environment (Rails 3.2.3)
irb(main):001:0> u = User.new
=> #<User id: nil, email: "", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, authentication_token: nil, created_at: nil, updated_at: nil, short_name: nil, invited_by_id: nil, name: nil, group_id: nil, first_time_email: true, first_time_web: true, first_time_password: nil, terms: nil, pref_send_me_email_updates: true, pref_send_me_my_email_updates: false>
irb(main):002:0> u.terms
=> nil
i
2012-07-02T22:02:04+00:00 app[web.1]: ActionView::Template::Error (undefined method `terms' for #<User:0x007f94981cce68>):
2012-07-02T22:02:04+00:00 app[web.1]: 39: .clear
2012-07-02T22:02:04+00:00 app[web.1]: 40: %p.tos
2012-07-02T22:02:04+00:00 app[web.1]: 41: - f.label :terms, "Terms Of Use"
2012-07-02T22:02:04+00:00 app[web.1]: 42: = f.check_box :terms
2012-07-02T22:02:04+00:00 app[web.1]: 43: By clicking the checkbox, you accept our
2012-07-02T22:02:04+00:00 app[web.1]: 44: %a{:href => '/terms-of-use', :target => '_blank'}
2012-07-02T22:02:04+00:00 app[web.1]: 45: terms of use.
2012-07-02T22:02:04+00:00 app[web.1]: app/views/devise/registrations/new.haml:42:in `block in _app_views_devise_registrations_new_ha
@tensiondriven
Copy link
Author

attr_accessible :email, :password, :password_confirmation, :remember_me,
:short_name, :name, :invited_by, :group, :first_time_email, :first_time_web, :first_time_password, :terms

attr_accessible :title, :body

belongs_to :invited_by, :class_name => 'User'

has_many :goals, :foreign_key => 'created_by'
has_many :updates, :through => :updates_users

belongs_to :group

default_scope :order => 'short_name ASC'

validates :email, :name, :presence => true
validates :email, :short_name, :uniqueness => { :case_sensitive => false }

validates :short_name, :presence => true, :length => { :maximum => 10, :minimum => 3}

validates_format_of :short_name, :with => /[\w .-@]+/

validates_presence_of :terms, :accept => '1', :message => 'must be accepted'

before_create :init_defaults

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment