我正在尝试设置设计,要求管理员在用户登录前批准注册请求。
当我尝试填写注册表单时,我的user.rb文件中出现以下错误。
SyntaxError at /users
syntax error, unexpected tIVAR, expecting keyword_do or '{' or '('
错误的引用在此方法中:
def send_admin_mail
AdminMailer.new_user_waiting_for_approval(self).deliver
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# do i need a session controller for users? I have user/registration_controller and user/omniauth controller only?
after_create :send_admin_mail
mount_uploader :avatar, AvatarUploader
acts_as_messageable
# --------------- associations
has_one :account_history
has_one :shortlist
has_one :match_maker
has_many :authentications
has_many :relationships, foreign_key: "follower_id", dependent: :destroy
has_many :followed_users, through: :relationships, source: :followed
has_many :followers, through: :reverse_relationships
# --------------- validations
# --------------- class methods
def send_admin_mail
AdminMailer.new_user_waiting_for_approval(self).deliver
end
def disapprove
self.approved = false
end
def approve
self.approved = true
end
def active_for_authentication?
super && approved?
end
def inactive_message
if !approved?
:not_approved
else
super # Use whatever other message
end
end
def self.send_reset_password_instructions(attributes={})
recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
if !recoverable.approved?
recoverable.errors[:base] << I18n.t("devise.failure.not_approved")
elsif recoverable.persisted?
recoverable.send_reset_password_instructions
end
recoverable
end
end
# ---- Greeting
def sayHello(first_name)
"Hello, #{first_name.capitalize}"
end
请任何人都可以帮忙。我无法看到错误的位置。这让我感到沮丧。谢谢。