I think you may have error messages and flash messages mixed up. When you get errors being shown through the <%= devise_error_messages! %>
, those error messages are coming from the validations that are set on the model. For example in the User
model,
validates :password, presence: true
These are different errors compared to the flash messages. You set flash
messages in the controller like this
def create
# code .....
if @post.save
flash[:success] = "Post was successfully created"
redirect_to [@investigation, @post]
else
flash.now[:error] = "Post was not created"
render 'new'
end
end
These flash messages just respond to the conditions you specify in the controller actions. Hope this helps