Permalink
Browse files

scope unique username per admin

  • Loading branch information...
1 parent 7cf05d7 commit 24e53723de8a4f2aca4e938cd4e86b404cb4694a @schneems committed Apr 26, 2011
Showing with 4 additions and 3 deletions.
  1. BIN .DS_Store
  2. +2 −1 app/controllers/admins_controller.rb
  3. +2 −2 app/models/user.rb
  4. BIN public/system/avatars/65/medium/50109_12803489_6139044_n.jpg
  5. BIN public/system/avatars/65/original/50109_12803489_6139044_n.jpg
  6. BIN public/system/avatars/65/thumb/50109_12803489_6139044_n.jpg
  7. BIN public/system/avatars/66/medium/cat_cougar.jpeg
  8. BIN public/system/avatars/66/original/cat_cougar.jpeg
  9. BIN public/system/avatars/66/thumb/cat_cougar.jpeg
  10. BIN public/system/avatars/67/medium/cat_dog_fox.jpeg
  11. BIN public/system/avatars/67/original/cat_dog_fox.jpeg
  12. BIN public/system/avatars/67/thumb/cat_dog_fox.jpeg
  13. BIN public/system/avatars/68/medium/cat_hyena.jpeg
  14. BIN public/system/avatars/68/original/cat_hyena.jpeg
  15. BIN public/system/avatars/68/thumb/cat_hyena.jpeg
  16. BIN public/system/avatars/69/medium/cat_lion.jpeg
  17. BIN public/system/avatars/69/original/cat_lion.jpeg
  18. BIN public/system/avatars/69/thumb/cat_lion.jpeg
  19. BIN public/system/avatars/70/medium/cat_tiger.jpeg
  20. BIN public/system/avatars/70/original/cat_tiger.jpeg
  21. BIN public/system/avatars/70/thumb/cat_tiger.jpeg
  22. BIN public/system/avatars/71/medium/cat_white_tiger.jpeg
  23. BIN public/system/avatars/71/original/cat_white_tiger.jpeg
  24. BIN public/system/avatars/71/thumb/cat_white_tiger.jpeg
  25. BIN public/system/avatars/72/medium/pirate_bay.jpeg
  26. BIN public/system/avatars/72/original/pirate_bay.jpeg
  27. BIN public/system/avatars/72/thumb/pirate_bay.jpeg
  28. BIN public/system/avatars/73/medium/pirate_blackbeard.jpeg
  29. BIN public/system/avatars/73/original/pirate_blackbeard.jpeg
  30. BIN public/system/avatars/73/thumb/pirate_blackbeard.jpeg
  31. BIN public/system/avatars/74/medium/pirate_cat.jpeg
  32. BIN public/system/avatars/74/original/pirate_cat.jpeg
  33. BIN public/system/avatars/74/thumb/pirate_cat.jpeg
  34. BIN public/system/avatars/75/medium/pirate_dog.jpeg
  35. BIN public/system/avatars/75/original/pirate_dog.jpeg
  36. BIN public/system/avatars/75/thumb/pirate_dog.jpeg
  37. BIN public/system/avatars/76/medium/pirate_fake.jpeg
  38. BIN public/system/avatars/76/original/pirate_fake.jpeg
  39. BIN public/system/avatars/76/thumb/pirate_fake.jpeg
  40. BIN public/system/avatars/77/medium/pirate_morgan.jpeg
  41. BIN public/system/avatars/77/original/pirate_morgan.jpeg
  42. BIN public/system/avatars/77/thumb/pirate_morgan.jpeg
  43. BIN public/system/avatars/78/medium/pirate_ninja.jpeg
  44. BIN public/system/avatars/78/original/pirate_ninja.jpeg
  45. BIN public/system/avatars/78/thumb/pirate_ninja.jpeg
View
BIN .DS_Store
Binary file not shown.
@@ -44,8 +44,9 @@ def create
def seed
return false if current_admin.blank? || (taxonomy = params[:taxonomy].downcase.to_s).blank?
Dir[Rails.root.join("public/images/#{taxonomy}/*.jpeg")].each do |file|
+ image = open(file)
username = file.match(/([^\/]*)\.jpeg$/) && ($1).to_s
- current_admin.users.create(:username => username, :avatar => open(file))
+ current_admin.users.create(:username => username, :avatar => image)
end
redirect_to admin_path(current_admin)
end
View
@@ -1,5 +1,5 @@
class User < ActiveRecord::Base
- validates_uniqueness_of :username
+ validates_uniqueness_of :username, :scope => :admin_id
has_many :friendships, :foreign_key => "user_1_id", :dependent => :destroy
has_many :friends, :through => :friendships, :source => :user_2, :conditions => "status = 'accepted'"
@@ -14,7 +14,7 @@ class User < ActiveRecord::Base
c.require_password_confirmation = false
c.validate_password_field = false
c.ignore_blank_passwords = false
- c.validate_login_field = false
+ c.validate_login_field = false
c.validate_email_field = false
end
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.

0 comments on commit 24e5372

Please sign in to comment.