Advertisement
Guest User

Untitled

a guest
Oct 6th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. ## user.rb model
  2. class User < ActiveRecord::Base
  3. # Include default devise modules. Others available are:
  4. # :http_authenticatable, :token_authenticatable, :confirmable, :lockable, :timeouta
  5. devise :registerable,
  6. :database_authenticatable,
  7. :recoverable,
  8. #:rememberable,
  9. :trackable,
  10. :validatable
  11.  
  12. # Setup accessible (or protected) attributes for your model
  13. attr_accessible :email, :password, :password_confirmation, :username, #core in the
  14. :givenName, :sn # "virtual for ldap"
  15.  
  16. before_create :try_add_ldap
  17. before_update :try_update_ldap
  18. before_destroy :try_destroy_ldap
  19.  
  20. private
  21. def pass_ssha(password)
  22. ActiveLdap::UserPassword.ssha(password)
  23. end
  24.  
  25. def try_add_ldap
  26. ldap = LdapUser.new(:uid => self.username,
  27. :givenName => self.givenName,
  28. :cn => "#{self.givenName} #{self.sn}",
  29. :sn => self.sn,
  30. :mail => "#{self.username}@empiregameleague.com",
  31. :physicalDeliveryOfficeName => self.email,
  32. :userPassword => pas_ssha(self.password)
  33. )
  34. if ldap.save
  35. return true
  36. else
  37. errors.add(:ldap, "user was not able to be written")
  38. return false
  39. end
  40. end
  41.  
  42. ## eNoMethodError in Registrations#new
  43.  
  44. Showing app/views/registrations/new.html.haml where line #12 raised:
  45.  
  46. undefined method `givenName' for #<User:0x7f7f1b4511f8>
  47.  
  48. Extracted source (around line #12):
  49.  
  50. 9: = f.input :password_confirmation
  51. 10: = f.inputs :name => "Personal Information", :id => "personal" do
  52. 11: = f.input :givenName
  53. 12: = f.input :sn
  54. 13: = f.buttons
  55. 14: = render :partial => "shared/devise_links"
  56.  
  57. RAILS_ROOT: /var/www/rails/rubyportal
  58. Application Trace | Framework Trace | Full Trace
  59.  
  60. Request
  61.  
  62. Parameters:
  63.  
  64. None
  65.  
  66. Show session dump
  67. Response
  68.  
  69. Headers:
  70.  
  71. {"Content-Type"=>"text/html",
  72. "Cache-Control"=>"no-cache"}
  73.  
  74. rror
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement