Skip to content

Instantly share code, notes, and snippets.

@visdesarrollo2
Forked from suryart/application.html.erb
Last active August 29, 2015 14:14

Revisions

  1. @suryart suryart revised this gist Jun 28, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion application_helper.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    module ApplicationHelper

    def bootstrap_class_for flash_type
    { success: "alert-success", error: "alert-error", alert: "alert-warning", notice: "alert-info" }[flash_type] || flash_type.to_s
    { success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }[flash_type] || flash_type.to_s
    end

    def flash_messages(opts = {})
  2. @suryart suryart revised this gist Nov 11, 2013. 1 changed file with 1 addition and 12 deletions.
    13 changes: 1 addition & 12 deletions application_helper.rb
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,7 @@
    module ApplicationHelper

    def bootstrap_class_for flash_type
    case flash_type
    when :success
    "alert-success"
    when :error
    "alert-error"
    when :alert
    "alert-warning"
    when :notice
    "alert-info"
    else
    flash_type.to_s
    end
    { success: "alert-success", error: "alert-error", alert: "alert-warning", notice: "alert-info" }[flash_type] || flash_type.to_s
    end

    def flash_messages(opts = {})
  3. @suryart suryart renamed this gist Nov 11, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @suryart suryart created this gist Nov 11, 2013.
    10 changes: 10 additions & 0 deletions application.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    // layout file

    <body>
    <div class="container">

    <%= flash_messages %>

    <%= yield %>
    </div><!-- /container -->
    </body>
    27 changes: 27 additions & 0 deletions application_helper.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    module ApplicationHelper

    def bootstrap_class_for flash_type
    case flash_type
    when :success
    "alert-success"
    when :error
    "alert-error"
    when :alert
    "alert-warning"
    when :notice
    "alert-info"
    else
    flash_type.to_s
    end
    end

    def flash_messages(opts = {})
    flash.each do |msg_type, message|
    concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} fade in") do
    concat content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' })
    concat message
    end)
    end
    nil
    end
    end