Questions tagged [rails-flash]

In Rails framework, The flash is a special part of the session which is cleared with each request. It is intended to be used for carrying request responses to views.

30 questions
72
votes
6 answers

How to display a Rails flash notice upon redirect?

I have the following code in a Rails controller: flash.now[:notice] = 'Successfully checked in' redirect_to check_in_path Then in the /check_in view:

<%= notice %>

However, the notice does not show up. Works perfect if I don't…
at.
  • 50,922
  • 104
  • 292
  • 461
15
votes
2 answers

Accessing rails flash[:notice] in a model

I am trying to assign a message to flash[:notice] in a model observer. This question has already been asked: Ruby on Rails: Observers and flash[:notice] messages? However, I get the following error message when I try to access it in my…
titaniumdecoy
  • 18,900
  • 17
  • 96
  • 133
15
votes
3 answers

Rails doesn't display flash messages after ajax call

I'm writing a rails 4.0.2 app, and am trying to get a Flash notice to display in my view after an AJAX event. In my view I display a calendar with days a user can click on. When they do so, I fire an AJAX event via an onclick event handler which…
Donovan
  • 15,917
  • 4
  • 22
  • 34
12
votes
4 answers

How can I clear out the Rails flash object after responding to an Ajax request?

I am doing this type of thing for some of my controller actions: def my_method flash[:notice] = "Success." respond_to do |format| format.js { render 'common/flashes' } end end And it works great, and the flash alerts and notices show…
5
votes
2 answers

Rails flash with warning, alert and error not shown; only notice shown

In my view, I have: <% flash.now[:error] = "ERROR FLASH" %> <% flash.now[:notice] = "NOTICE FLASH" %> <% flash.now[:warning] = "WARNING FLASH" %> When the page gets render, only the blue info box with NOTICE FLASH appears. The other two will not…
RoundOutTooSoon
  • 9,821
  • 8
  • 35
  • 52
5
votes
3 answers

Replace devise_error_messages! with flash messages

I generated my devise views using rails g devise:views users I generated my devise controllers using rails g devise:controllers users I added my new controllers in routes.rb: devise_for :users, controllers: { sessions: "users/sessions", …
4
votes
1 answer

Rails 3 notices

Using Rails 3.0.3 in combination with gems like devise I don't get any flash messages. Now I mention devise, because it controls the cookies used to authenticate me. Now the Rails application is a bit special since its using sub-domains. What they…
tombruijn
  • 1,130
  • 10
  • 13
2
votes
2 answers

Rails Flash doesn't behave as what the Rails Guide says

According to the official flash section on Rails Guide: The Flash The flash is a special part of the session which is cleared with each request. This means that values stored there will only be available in the next request, which is useful for…
Trantor Liu
  • 8,770
  • 8
  • 44
  • 64
2
votes
2 answers

Rails error and notice flash not showing properly with css styling

I have a simple controller which checks the validity of an ActiveModel. If the model is valid it displays :success flash message. If it is not, it displays error flash message. The success flash message is displayed correctly (green font and…
2
votes
2 answers

How to pass form errors in session or flash? [Rails 2.3.5]

I have a create action for a form that potentially generates errors (i.e. first name is missing) and then redirects. The problem is, that when the redirect happens those form errors get lost. How could I pass those form errors in a session to be…
Yuval Karmi
  • 26,277
  • 39
  • 124
  • 175
2
votes
1 answer

Consistent displaying of flash messages and model validation errors in Ruby On Rails

Do people use a unified system for displaying flash messages and model validation errors in their apps? or do you keep them separate? Is there an accepted best practice? or would it be driven by where it visually makes sense to display them. This…
pingu
  • 8,719
  • 12
  • 50
  • 84
2
votes
1 answer

`flash.discard` in Rails 2.3 fails because flash is a Hash, not a FlashHash

Given a functional test such as: def test_exciting_rails_upgrades login(m=users(:manager)) post :import_users_map_fields, :csv_file => fixture_file_upload('/users.csv', 'text/csv') assert flash.empty? flash.discard # other…
JD.
  • 3,005
  • 2
  • 26
  • 37
1
vote
1 answer

How do you simulate a Rails error flash in jsp?

Is there a jsp/jstl equivalent of this Rails error flash? <%- flash.each do |name, msg| -%> <%= content_tag :div, msg, :id => "flash_#{name}" %> <%- end -%> I've been looking for a pre-built solution that is as simple as this Rails…
peasoup
  • 101
  • 1
  • 5
1
vote
1 answer

Ruby on rails flash notice error

I have a problem with flash[:notice] = "Message" in Ruby on Rails. I am trying to create login fault error message. My login fault handling is: flash[:notice] = "Invalid username/password combination." redirect_to(:action => 'login') For the…
1
vote
0 answers

Rails: notice: messages won't disappear Using rails_layout gem?

I'm not sure if this is a bug or what, but the notice messages are not disappearing and I have looked at a bunch of other examples, none of them explain my case: like these: Why flash message won't disappear? rails 4 -- flash notice Rails flash…
0bserver07
  • 3,390
  • 1
  • 28
  • 56
1
2