Module: UrlHelper
- Defined in:
- app/helpers/url_helper.rb
Constant Summary collapse
- BUTTON_CLASSES =
['btn-default', 'btn-primary', 'btn-success', 'btn-info', 'btn-warning', 'btn-danger', 'btn-link'].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(class_) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/url_helper.rb', line 5 def self.included(class_) class_.class_eval do def (*args, &proc) args << nil if args.length < 2 args << {} if args.length < 3 (*args, &proc) super(*args, &proc) end end end |
Instance Method Details
#button_to_with_bootstrap(name = nil, options = nil, html_options = {}, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/url_helper.rb', line 16 def (name = nil, = nil, = {}, &block) [:class] ||= [] [:class] = [*[:class]] # Expand space-separated class strings so that each has its own spot in the class array [:class] = [:class].map { |c| c.split }.flatten [:class].unshift('btn') unless [:class].include?('btn') if [:class].select { |cls| UrlHelper::BUTTON_CLASSES.include?(cls) }.empty? [:class] << 'btn-default' end end |