mercredi 6 septembre 2017

I would like to know how to show an error message in my rails project? Thanks :)

I would like to know how to show an error message in my rails project? but I do not know how to implement an error message for the user. I think I could put this solution inside the 'if'. Someone Can help me or there is other solution? Thanks :))

class User < ActiveRecord::Base

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :ldap_authenticatable,:rememberable, :trackable

  #validates :username, presence: true, uniqueness: true

  #before_validation :get_ldap_email
  validates_uniqueness_of :email, :allow_blank => true

  before_save :get_ldap_email


  def get_ldap_email

    ldapEmail =  Devise::LDAP::Adapter.get_ldap_param(self.username,"mail")
      self.email = Devise::LDAP::Adapter.get_ldap_param(self.username,"mail").first

     if Devise::LDAP::Adapter.get_ldap_param(self.username,"mail") == null

     end

     else

     end

  end
  # use ldap uid as primary key
  #before_validation :get_ldap_id
  #def get_ldap_id
   # self.id = Devise::LDAP::Adapter.get_ldap_param(self.username,"uidnumber").first
  #end

  # hack for remember_token
  #def authenticatable_token
  #  Digest::SHA1.hexdigest(email)[0,29]
  #end
  has_many :votes , :dependent => :delete_all
  has_many :ideas , :dependent => :delete_all
end

Aucun commentaire:

Enregistrer un commentaire