Kees Sonnema
Kees Sonnema

Reputation: 5784

a way to dismiss the notice flash message in rails 3.2

is there a way to dismiss the standard rails 3.2 forum notice when created a record or logged in with devise? like in twitter-bootstrap there's a cross you can click to dismiss the notice message.

I hope there is a similar way in standard forms.

Upvotes: 1

Views: 3691

Answers (2)

Jesse Wolgamott
Jesse Wolgamott

Reputation: 40277

You asked if there was a simpler way. There is no built in way to do this.... You will need to do something like this:

<% if flash[:notice] %>
  <p class="notice"><%= flash[:notice] %></p>
<% end %>
<% if flash[:error] %>
  <p class="error"><%= flash[:error] %></p>
<% end %>

In your app/assets/javascripts/flash.js.coffee

$ ->
  $(".notice, .error").on("click", (event)->
    $(event.target).hide("slow")
  )

This will make it where if you click on the .notice or .error, it will hide the slowly (fade out). To this you can include a X icon to close it.

Upvotes: 11

urjit on rails
urjit on rails

Reputation: 1893

As I understand you not want notice on any particular action so delete <%= notice%> from application.rb file from your layout folder in view.

I hope i understood your question correctly.

Upvotes: 0

Related Questions