Menu suspenso não mostrando / trabalhando em trilhos [fechado]

0

O menu suspenso "Selecionar banco de dados" e "Selecionar tabela" não funciona.

arquivo _header.html.erb

<header class="navbar navbar-fixed-top navbar-inverse">
      <div class="container">
        <%= link_to "Database Management", root_path, id: "logo" %>
        <nav>
          <ul class="nav navbar-nav navbar-right">
            <li><%= link_to "Home",   root_path %></li>
            <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            SelectTable <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
            <%  if $l == 1 %>
              <% for items in $selectedtable %>    
                <li><%= link_to items, currenttable_path %> </li> 
                <% $gh = item %>
              <% end %> 
            <% end %>
            </ul>

            <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            SelectDatabase <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
            <% for item in $selecteddatabase %>  
              <li><%= link_to item, currentdatabase_path %></li> 
              <% $gy = item %>
            <% end %>
            </ul>
            <li><%= link_to "NewTable", newtable_path %></li>
            <li><%= link_to "NewDatabase", newdatabase_path %></li>
            <li><%= link_to "DeleteTable", deletetable_path %></li>
            <li><%= link_to "DeleteDatabase", deletedatabase_path %></li>
            <li><%= link_to "Connect", connect_path %></li>
            <li><%= link_to "Disconnect", disconnect_path %></li>
            <li><%= link_to "Administration", administration_path %></li>
            <li><%= link_to "Quit", quit_path %></li>
          </ul>
        </nav>
      </div>
</header>

application.html.erb file

<!DOCTYPE html>
<html>
  <head>
    <title><%= full_title(yield(:title)) %></title>
    <%= stylesheet_link_tag 'application', media: 'all',
                                           'data-turbolinks-track' => true %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    <%= csrf_meta_tags %>
    <%= render 'layouts/shim' %>

  </head>
  <body>
    <%= render 'layouts/header' %>
        <div class="container">
      <% flash.each do |message_type, message| %>
        <%= content_tag(:div, message, class: "alert alert-#{message_type}") %>
      <% end %>
      <%= yield %>
      <%= render 'layouts/footer' %>
      <%= debug(params) if Rails.env.development? %>
    </div>
  </body>
</html>

arquivo application_controller.rb

require 'mysql2'
class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
  $con = Mysql2::Client.new(host: "localhost", username: "root", password: "new_password", database: "mysql")

  before_filter :assign_header_variables

  def assign_header_variables
    rs = $con.query("SHOW databases")
    i = 0 
    for y in rs
    i = i + 1
    end
    c = 0
    $selecteddatabase = Array.new(i)
    for item in rs 
      $selecteddatabase[c] = item
      c = c + 1
    end

    if $l == 1
      ts = $con.query("SHOW tables")
      i = 0 
      for y in ts
        i = i + 1
      end
      k = 0 
      $selectedtable = Array.new(i)
      for items in ts do 
        $selectedtable[k] = items 
        k = k + 1
      end
    end
  end
end
    
por Tamal Chakraborty 25.06.2015 / 13:15

1 resposta

0

Encontrei a resposta para o problema.

Adicionando a biblioteca JavaScript do Bootstrap ao application.js. app / assets / javascripts / application.js

  • // = requer jquery
  • // = requer jquery_ujs
  • //= require bootstrap
  • // = requer turbolinks
  • // = require_tree.
por Tamal Chakraborty 26.06.2015 / 03:30