为什么dropdown-toggle(bootstrap)在heroku上不起作用? [英] Why does dropdown-toggle (bootstrap) not work on heroku?

查看:157
本文介绍了为什么dropdown-toggle(bootstrap)在heroku上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么我的视图(标题栏)中的以下代码在heroku上不起作用。



它似乎对开发和在本地服务器上生产。一旦我推到heroku,生成的html也是很好的。所有其他自举元素似乎都可以工作。然而,这个下拉链接似乎不起作用

 <%if current_user.present? %GT; 


< div id =accountclass =dropdown>

< a href ='#'class =dropdown-toggledata-toggle =dropdown>
< span>帐户< / span> < b class =caret>< / b>
< / a>
< ul class =dropdown-menu pull-right>
< li><%= link_to个人资料,current_user%>< / li>
< li><%= link_to设置,edit_user_path(current_user)%>< / li>
< li class =divider>< / li>
< li>
<%= link_to退出,signout_path,方法:删除%>
< / li>
< / ul>

< / div>
<%end%>

生成的HTML:

 < div id =accountclass =dropdown> 

< a href ='#'class =dropdown-toggledata-toggle =dropdown>
< span>帐户< / span> < b class =caret>< / b>
< / a>
< ul class =dropdown-menu pull-right>
< li>< a href =/ users / 1>个人资料< / a>< / li>
< li>< a href =/ users / 1 / edit>设置< / a>< / li>
< li class =divider>< / li>
< li>
< a href =/ signoutdata-method =delete =nofollow>退出< / a>
< / li>
< / ul>

< / div>

< / div>

我的应用程序/资产/样式表/ application.css

  * =需要自定义

我的应用/资产/stylesheets/custom.css.scss

  @importbootstrap; 

我对heroku很新颖。所以我不知道如何调试这样的错误。这怎么能解决我如何调试这样的错误?

解决方案

在rails中有一些奇怪的错误:我的application.js最初是:

  // =需要jquery 
// =需要jquery_ujs
// =需要jquery-ui
// =需要引导程序

我必须对它重新排序并将引导程序提前移至jquery



修改后的application.js

  // =需要引导
// =需要jquery
// =需要jquery_ujs
// =要求jquery-ui

然后我必须运行 p>

  heroku运行rake资产:重设
heroku运行rake资产:预编译

现在它可以工作

I do not understand why the following piece of code in my view (title bar) does not work on heroku.

It seems to work fine on both development and production on my local server. Once i push to heroku, the html generated is also good. All other bootstrap elements seem to work. However, this dropdown link does not seem to work

    <% if current_user.present? %>


                <div id = "account" class=" dropdown">

                        <a href='#' class="dropdown-toggle" data-toggle="dropdown">
                            <span>Account</span> <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><%= link_to "Profile", current_user %></li>
                            <li><%= link_to "Settings", edit_user_path(current_user) %></li>
                            <li class="divider"></li>
                            <li>
                                <%= link_to "Sign out", signout_path, method: "delete" %>
                            </li>
                        </ul>

                </div>
                <% end %>

The HTML generated:

                <div id = "account" class=" dropdown">

                        <a href='#' class="dropdown-toggle" data-toggle="dropdown">
                            <span>Account</span> <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a href="/users/1">Profile</a></li>
                            <li><a href="/users/1/edit">Settings</a></li>
                            <li class="divider"></li>
                            <li>
                                <a href="/signout" data-method="delete" rel="nofollow">Sign out</a>
                            </li>
                        </ul>

                </div>

                </div>

my app/assets/stylesheets/application.css

 * = require custom

my app/assets/stylesheets/custom.css.scss

@import "bootstrap";

I am pretty new to heroku. So i am not aware of how to debug such an error. How can this be sorted out how i can debug such an error?

解决方案

Some strange bug in rails: my application.js was initially:

//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require bootstrap

I had to reorder it and move bootstrap ahead of jquery

Modified application.js

//= require bootstrap
//= require jquery
//= require jquery_ujs
//= require jquery-ui

And then I had to run

heroku run rake assets:reset
heroku run rake assets:precompile

Now it works

这篇关于为什么dropdown-toggle(bootstrap)在heroku上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆