drhenner / ror_ecommerce

Ruby on Rails Ecommerce platform, perfect for your small business solution.
www.ror-e.com
MIT License
1.21k stars 409 forks source link

Flash message not work #143

Closed tamvm closed 10 years ago

tamvm commented 10 years ago

I can't understand why flash message doesn't show after redirect. Is there any suggestion?

drhenner commented 10 years ago

Can you give me the exact steps to reproduce? Login? Checkout?

Are you logged in as an admin or normal user?

tamvm commented 10 years ago

Oh, thanks a lot for your quick response. I'm ridiculous with this issue, before on other project, I do the the same, but it worked. To reproduce, please follow following steps:

  1. Create sample action: (for example: UserSessionController#test)
  def test
    flash[:notice] = "asdasd"
    flash.keep
    redirect_to root_url, flash: {error: "asdasd"}
  end
  1. In WelcomeController#index or in welcome/index view: puts byebug and check flash variable.

Thanks for your contribution, the project is so great anyway, it save a lot of my effort.

tamvm commented 10 years ago

Does it work on your machine?

drhenner commented 10 years ago

I'm not going to have time to test this today. I'm curious if this is a just a rendering issue.

also try alert instead of error

 redirect_to root_url, flash: {alert: "asdasd"}
tamvm commented 10 years ago

I tested with many ways (include yours) but no luck :(. It's fine, just focus on your work first.

drhenner commented 10 years ago

Is this on your local machine? Do you have memcached running?

tamvm commented 10 years ago

Yes, it doesn't work on my local, I don't think it's related to memcached, but I also just tried to run memcached inline too, but it doesn't work too. Can't understand.

tamvm commented 10 years ago

Finally I knew the problem, I follow the comment in config/initializers/session_store.rb and uncomment the line: Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 30.minutes

I commented that line and now it worked normally. Anyway, thanks for your help, I'm closing this issue right now.