0

I had my "create" method in my registration controller (devise) working just fine, flash messages and all. Then I exported it out to a module, because I needed to access that method from another controller. It is working just fine, except the flash messages mysteriously stopped working. If I copy the code back to the registrations controller, the messages work fine again.

The controller:

require 'create_user'
class RegistrationsController < ApplicationController
  include CreateUser
  .
  # Stuff
  .
end

The module, located in app/modules:

module CreateUser
  def create
    flash[:notice] = "test" # obviously created to test the messages
    .
    # other stuff
    .
  end
end

I've tried changing CreateUser to a class, to have it be under the ApplicationsController, and the ActionBase itself as a module. But those messages do not work unless the code is directly in the controller. The flash messages are loaded directly from the layout, so I don't believe that is the problem. Any ideas?

Chris Burrus
  • 187
  • 9
  • 1
    check this http://stackoverflow.com/questions/4101641/rails-devise-handling-devise-error-messages – Arvind Aug 21 '15 at 17:21
  • Never figured out why I can't use flash[:error], but I changed to using the notices/alerts/etc as part of my redirect_to, such as `redirect_to new_user_session_path, :notice => "Thank you for signing up. Please check your email to confirm your account before logging in."` - and now everything works fine. – Chris Burrus Aug 21 '15 at 18:03

1 Answers1

0

Never figured out why I can't use flash[:error], but I changed to using the notices/alerts/etc as part of my redirect_to, such as

redirect_to new_user_session_path, :notice => "Thank you for signing up. Please check your email to confirm your account before logging in."

and now everything works fine.

Chris Burrus
  • 187
  • 9