0
由於我使用的api,我需要取出Devise的registrationsController創建操作。除了一個,我已經得到了這個工作。出於某種原因,set_flash_message方法返回錯誤:設計set_flash_message!不在定製設計控制器中工作
NoMethodError - undefined method `set_flash_message!' for #<Users::RegistrationsController:0x007f91f8e8b070>:
app/controllers/users/registrations_controller.rb:28:in `create'
這裏是控制器代碼:
class Users::RegistrationsController < Devise::RegistrationsController
def create
build_resource(sign_up_params)
resource.save!
yield resource if block_given?
if resource.persisted?
puts "resource persisted".green
if resource.active_for_authentication?
flash[:success] = "Welcome! You have signed up successfully."
# set_flash_message! :notice, :signed_up
sign_up(resource_name, resource)
respond_with resource, location: after_sign_up_path_for(resource)
else
puts "not sure about this".blue
set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}"
# flash[:danger] = "signed_up_but_#{resource.inactive_message}"
expire_data_after_sign_in!
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
else
puts "resource did not persist".red
clean_up_passwords resource
set_minimum_password_length
# respond_with resource
puts "NOW WE KNOW".on_red
render 'new' #not sure if this works
end
end
end
我已經把提示信息以正常的方式進行,但現在它已經引發了一些問題。我如何讓set_flash_message發揮作用?
這爲我工作,謝謝 – gusridd