Sha256: 1f97357cce7bf7e507733069506be001390b590be70654fbb0ba3bde18f2aaa8
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
class <%= class_name %> < ActiveRecord::Base hobo_user_model # Don't put anything above this fields do name :string, :unique email_address :email_address, :unique, :login => true administrator :boolean, :default => false timestamps end # This gives admin rights to the first sign-up. # Just remove it if you don't want that before_create { |user| user.administrator = true if RAILS_ENV != "test" && count == 0 } # --- Signup lifecycle --- # lifecycle do state :active, :default => true create :signup, :available_to => "Guest", :params => [:name, :email_address, :password, :password_confirmation], :become => :active transition :request_password_reset, { :active => :active }, :new_key => true do <%= class_name %>Mailer.deliver_forgot_password(self, lifecycle.key) end transition :reset_password, { :active => :active }, :available_to => :key_holder, :params => [ :password, :password_confirmation ] end # --- Permissions --- # def create_permitted? false end def update_permitted? acting_user.administrator? || (acting_user == self && only_changed?(:crypted_password, :email_address)) # Note: crypted_password has attr_protected so although it is permitted to change, it cannot be changed # directly from a form submission. end def destroy_permitted? acting_user.administrator? end def view_permitted?(field) true end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hobo-0.8.6 | rails_generators/hobo_user_model/templates/model.rb |
hobo-0.8.7 | rails_generators/hobo_user_model/templates/model.rb |