I'm rewriting a Rails 4.2.2 application to Rails 4.2.5 because of a security update. I'm running Ruby 2.2.2 in the 4.2.2 application. In the 4.2.2 application I'm using gem twitter-bootstrap-rails for Bootstrap 2. Unfortunately I can no longer use that version of the gem in Rails 4.2.5 because of a Ruby error. I submitted an issue in GitHub but no one ever responded. I decided to upgrade my application to Ruby 2.3.0 and Rails 4.2.5.1 and use the latest version of gem bootstrap-sass for Bootstrap 2.
In my old application using gem twitter-bootstrap-rails I had code that successfully displayed a partial as a popover. The code examples below are in my 4.2.5 application using bootstrap-sass.
CSS
app/assets/stylesheets/custom.css.scss
@import "bootstrap";
.popover { max-width: none; }
JS
app/assets/javascripts/bootstrap.js.coffee (created by gem twitter-bootstrap-rails)
jQuery ->
$(".popover-map").popover({ html : true })
# $("a[rel~=popover], .has-popover").popover()
app/assets/javascripts/application.js
//= require bootstrap
Rails partial code
<%= link_to("#{t :map_marfa_head}" , '#', class: "popover-map", rel: "popover", title: "#{t :map_marfa_head}", :"data-placement" => "bottom", :"data-content" => "#{render 'pages/map_marfa'}") %>
I checked the source of the page where my Rails partial code is and saw the following error.
TypeError: $(".popover-map").popover is not a function. (In '$(".popover-map").popover({
html: true
})', '$(".popover-map").popover' is undefined)
(anonymous function)bootstrap.self-a54a326f6cd027d08c61488151646f3b32c14ca968788b351d38b24c02b72000.js:2
firejquery.self-c64a74367bda6ef8b860f19e74df08927ca99d2be2ac934e9e92d5fd361e0da4.js:3232
fireWithjquery.self-c64a74367bda6ef8b860f19e74df08927ca99d2be2ac934e9e92d5fd361e0da4.js:3362
readyjquery.self-c64a74367bda6ef8b860f19e74df08927ca99d2be2ac934e9e92d5fd361e0da4.js:3582
completedjquery.self-c64a74367bda6ef8b860f19e74df08927ca99d2be2ac934e9e92d5fd361e0da4.js:3617
It appears that the popover function is undefined but the way the error is worded I'm not really sure. How do I include the popover script in Rails? Do I need to add an additional import statement in my stylesheet or do I need to create a popover.js/popover.js.coffee/popover.coffee file? The bootstrap-sass gem GitHub documentation says that the entire Bootstrap package is included by default but some things need to be initialized.
I found this link but it is does not contain Rails specific information.
http://www.w3resource.com/twitter-bootstrap/popover-tutorial.php
UPDATE 2/23/2016 10:55 am CST
I decided to add the following statement to app/assets/javascripts/bootstrap.js.coffee since normally this code would work.
$("a[rel=popover]").popover()
Unfortunately I got the following error on this statement also.
TypeError: $("a[rel=popover]").popover is not a function. (In '$("a[rel=popover]").popover()', '$("a[rel=popover]").popover' is undefined)
(anonymous function)bootstrap.self-dd0727b0d7b4d50d5415be2857e6060f1fc2b8a195352a28af1f44d5b97ec59c.js:2
firejquery.self-c64a74367bda6ef8b860f19e74df08927ca99d2be2ac934e9e92d5fd361e0da4.js:3232
fireWithjquery.self-c64a74367bda6ef8b860f19e74df08927ca99d2be2ac934e9e92d5fd361e0da4.js:3362
readyjquery.self-c64a74367bda6ef8b860f19e74df08927ca99d2be2ac934e9e92d5fd361e0da4.js:3582
completedjquery.self-c64a74367bda6ef8b860f19e74df08927ca99d2be2ac934e9e92d5fd361e0da4.js:3617
I'm still looking for posts for this error when using bootstrap-sass in Rails. I searched the GitHub documentation and issues sections for the gem and found absolutely nothing to help me.
I will keep looking.
After my initial attempt with using twitter-bootstrap-rails with Ruby 2.2.2 and Rails 4.2.5 I saw a security update for Ruby. I upgraded Ruby to 2.3.0. I submitted this issue in GitHub but it was never assigned. Since no one had responded I decided to try twitter-bootstrap-rails again and the popover worked as before. It appears that bootstrap-sass for Bootstrap 2 no longer has the scripts for popover or tooltip.