1
我需要什麼,如果一些用戶有一個屬性,這將不需要確認。 我見過一些關於此的帖子,但我無法理解它(我在Rails中有點新手)。設計 - 有可能某些用戶不需要確認嗎?
在我user.rb
def confirmation_required?
if self.name == 'Joe'
false
end
end
我試過了,但沒有任何反應,就像是永遠是假的。我看到另一篇與此代碼:
def confirmation_required?
!confirmed?
end
#Put your conditions and job's done !
,但我怎麼能訪問用戶數據從我user.rb(模型)注意,用戶來自HTTP POST請求。
有人可以幫我嗎?
感謝
編輯
而且我可能只是重新寫設計:: RegistrationsController到這樣的事情:
class RegistrationsController < Devise::RegistrationsController
def create
super do
if resource.name == 'Joe'
resource.skip_confirmation!
resource.save
end
end
end
end
你認爲這能解決嗎? 謝謝。
這麼簡單使用塊!男人非常感謝你! –