Guest User

Untitled

a guest
May 5th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. class Project < ActiveRecord::Base
  2. after_create :add_admin
  3. has_and_belongs_to_many :companies
  4. has_and_belongs_to_many :users
  5. has_many :mockups, :order => "updated_at DESC"
  6. has_many :jotters, :order => "created_at ASC"
  7. has_many :messages
  8. has_many :uploads, :order =>"created_at DESC"
  9. has_many :links
  10. belongs_to :account
  11.  
  12. def add_admin
  13. logger.info '#'*100+account.inspect
  14. @account = Account.find_by_id account_id
  15. self.user = @account.admin
  16. self.user.save
  17. end
  18.  
  19. end
  20.  
  21. ## Collection??
  22.  
  23. User Load (0.001697) SELECT * FROM `users` WHERE (`users`.account_id = 12 AND (`users`.`admin` = 1)) LIMIT 1
  24. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#<User id: 21, login: "blinkmg", email: "XXX", remember_token: nil, crypted_password: "5a7837c406bc76ece9b68b75f7b004b447ee8fe6", salt: "26d85631582838aa27530d5c74e5d7ef4c68de34", remember_token_expires_at: nil, updated_at: "2008-09-03 01:26:21", created_at: "2008-09-03 01:26:21", account_id: 12, admin: true, first_name: nil, last_name: nil, title: nil, phone: nil, mobile: nil, company_id: nil>
Add Comment
Please, Sign In to add comment