robinbrouwer / bootstrap_flash_messages Goto Github PK
View Code? Open in Web Editor NEWBootstrap alerts and Rails flash messages combined in one easy-to-use gem.
Bootstrap alerts and Rails flash messages combined in one easy-to-use gem.
Hello,
How should I use bootstrap_flash_messages when I have various error messages I'd like to display depending on the error? For example "E-mail address is mandatory." and "E-mail address is invalid."?
Thanks for your help,
David
I get this message when trying to show :flash => :notice from private message. Everything else seems to work perfectly...
def set_standard
@standard = Standard.for(current_user).find(params[:id])
rescue ActiveRecord::RecordNotFound
redirect_to(standards_path, :flash => :notice)
end
standards:
create:
success: "Reliability Standard has been created."
error: "Reliability Standard has not been created."
update:
success: "Reliability Standard has been updated."
error: "Reliability Standard has not been updated."
destroy:
success: "Reliability Standard has been deleted."
set_standard:
notice: "The Reliability Standard you were looking for could not be found."
Would it be possible to add the I18n interpolation feature to this gem (http://guides.rubyonrails.org/i18n.html#interpolation)?
The flash call could look something like this:
flash: :success, name: @user.name
and the locales file
en:
users:
create:
success: "%{name} has been successfully registered."
Hey,
Would appreciate support for either newlines (converting \n-s into br-s) or html notice messages. I need new lines in my notice and wasn't able to find a way to achieve it, but I want to keep using your gem.
Thanks!
the helper method flash_messages does not return html for me.
$("#flash_messages").html("#{j(flash_messages)}");
The default rails flash methods are :notice
and :error
. Currently, when using these in bootstrap_flash_messages, :error
renders correctly as alert-error
, but :notice
renders a normal yellow bootstrap alert
. Because the default rails flash is binary (success or fail), shouldn't any flash[:notice]
s translate to a bootstrap alert-success
?
If you don't want to do this by default, can you consider adding a configuration dictionary that will map any style to any bootstrap alert style? Something in an initializer like:
BootstrapFlashMessages.configuration.do |config|
config.alert_style_mapping = { :notice => :success, :foo => :info }
end
Then when displaying the alert class in the view, you can just look at the configuration to see if there is an override for the key
. In this case, flash[:notice]
would have an alert-success
class and flash[:foo]
would have a alert-info
class. Thoughts?
Sometimes we need to use
assert_redirected_to any_url
But when I have flash message, URL seems like any_url?flash=success. Than my test is failed.
assert_redirected_to "any/url?flash=success"
is bad idea.
error in before_filter method looks for error in target method, not before_filter method
#1) in rails controller
before_filter :default
def default
if error = true
redirect_to root_path, :flash => :error
end
end
def index; end
#2) browser attempts to hit controller#index but errors in default
#3) renders root_path view with this flash:
# "translation missing: en.flash_messages.controller_name.index.error
should the flash be: "translation missing: en.flash_messages.controller_name.default.error
?
raw('×')
close = link_to(raw('×'), "#", :class => "close", :data => { :dismiss => "alert" })
oooh! parser ....
& t i m e s ; = ×
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.