seyhunak / twitter-bootstrap-rails

Twitter Bootstrap for Rails 6.0, Rails 5 - Rails 4.x Asset Pipeline
https://github.com/seyhunak/twitter-bootstrap-rails
4.49k stars 997 forks source link

Warning: already initialized constant BootstrapFlashHelper::ALERT_TYPES #649

Closed tom-orrow closed 10 years ago

tom-orrow commented 11 years ago

There is unnecessary 'require' calls in lib/twitter/bootstrap/rails/engine.rb:

require File.dirname(__FILE__) + '/../../../../app/helpers/flash_block_helper.rb'
require File.dirname(__FILE__) + '/../../../../app/helpers/modal_helper.rb'
require File.dirname(__FILE__) + '/../../../../app/helpers/navbar_helper.rb'
require File.dirname(__FILE__) + '/../../../../app/helpers/bootstrap_flash_helper.rb'

Looks like they are already loaded and on each request BootstrapFlashHelper (for example) calls twice giving me this warning:

.../bundler/gems/twitter-bootstrap-rails-b4ec5166978a/app/helpers/bootstrap_flash_helper.rb:2: warning: already initialized constant BootstrapFlashHelper::ALERT_TYPES
.../bundler/gems/twitter-bootstrap-rails-b4ec5166978a/app/helpers/bootstrap_flash_helper.rb:2: warning: previous definition of ALERT_TYPES was here
dwormuth commented 10 years ago

Anyone have a solution to this?

denisahearn commented 10 years ago

We are also experiencing this. Is @g0ody's fix something that could be applied to this gem?

toadkicker commented 10 years ago

Closing since PR was merged

vanmart commented 7 years ago

in my case I use toastr-rails for pretty alerts or bootstrap_flash messages so, if you use this script from toastr gem documentation ` <% unless flash.empty? %>

    <script type="text/javascript">
            <% flash.each do |f| %>
              <% type = f[0].to_s.gsub('alert', 'error').gsub('notice', 'info') %>
              toastr['<%= type %>']('<%= f[1] %>');
          <% end %>
        </script>
   <% end %> ` 

just need remove this line on layouts or some views <%= bootstrap_flash %>