Rails flash mapping should translate better or be configurable #7

Closed
coneybeare opened this Issue Jan 16, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@coneybeare

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?

@RobinBrouwer

This comment has been minimized.

Show comment Hide comment
@RobinBrouwer

RobinBrouwer Jan 26, 2013

Owner

Thanks for your feedback. I just pushed v0.0.7 with alert_class_mapping. I didn't have a lot of time to add configuration like you did above, so it's a simple instance variable you can change inside an initializer. Check out the documentation how to use it. And I mapped :notice to 'alert-success' by default. Thanks again!

Owner

RobinBrouwer commented Jan 26, 2013

Thanks for your feedback. I just pushed v0.0.7 with alert_class_mapping. I didn't have a lot of time to add configuration like you did above, so it's a simple instance variable you can change inside an initializer. Check out the documentation how to use it. And I mapped :notice to 'alert-success' by default. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment