gpt4 book ai didi

ruby-on-rails - Rails 4 + bootstrap 设置 Assets

转载 作者:行者123 更新时间:2023-12-03 20:25:24 25 4
gpt4 key购买 nike

我正在尝试使用 bootstrap-sass 在 Rails4 上设置 Bootstrap 我得到了这个著名的错误:

Sprockets::FileNotFound - couldn't find file 'bootstrap'
(in app/assets/javascripts/application.js:16):

我试过以下:
  • twitter/bootstrapapplication.js
  • gem 'bootstrap-sass', '~> 3.1.0'属于集团外 Assets
  • 还尝试了互联网上的其他一些东西

  • 我花了很多时间从其他帖子中获取不同的建议。我如何系统地调试这个,如何设置 bootstrap-sass ?

    ps:
    也一直在尝试获取 twitter-bootstrap-rails没有运气的工作。

    这里有一些文件

    应用程序.js
    //= require jquery
    //= require jquery_ujs
    //= require js-routes
    //= require bootstrap
    //= require_tree .
    //= require bootstrap-slider

    应用程序.css.scss
     *= require jquery.ui.core
    *= require jquery.ui.theme
    *= require_self
    *= require bootstrap-slider
    *= require_tree .
    *= stub active_admin
    */

    @import "bootstrap";

    gem 文件
    source 'https://rubygems.org'
    ruby '2.0.0'
    gem 'rails', '4.0.0'
    gem 'sass-rails'
    gem 'coffee-rails', git: 'git://github.com/rails/coffee-rails.git'
    gem 'uglifier', '>= 1.0.3'
    gem 'jquery-ui-rails'
    gem 'font-awesome-sass'
    gem 'less-rails'
    gem 'therubyracer', :platform=>:ruby
    #gem 'twitter-bootstrap-rails'
    gem 'jquery-rails'
    #gem 'jquery_mobile_rails'
    gem 'js-routes'
    gem 'cancan'
    gem 'devise'
    gem 'figaro'
    gem 'haml-rails'
    gem 'pg'
    gem 'rolify'
    gem 'sendgrid'
    gem 'simple_form'
    gem 'thin'
    gem 'rake'

    #To use db for storing cookies instead cookie-store
    gem 'activerecord-session_store', github: 'rails/activerecord-session_store'

    group :development do
    gem 'better_errors'
    #gem 'binding_of_caller', :platforms=>[:mri_19, :rbx]
    #Commenting out platforms part, because may be that's stopping this to be used on the dev machine'
    gem 'binding_of_caller'
    gem 'guard-bundler'
    gem 'guard-rails'
    gem 'guard-rspec'
    gem 'html2haml'
    gem 'quiet_assets'
    gem 'rb-fchange', :require=>false
    gem 'rb-fsevent', :require=>false
    gem 'rb-inotify', :require=>false

    # Required with Rails panel chrome extension. This Gem should come after better_errors gem
    gem 'meta_request'
    end
    group :development, :test do
    gem 'factory_girl_rails'
    gem 'rspec-rails'
    gem 'pry-byebug'
    gem 'pry-stack_explorer'
    gem 'pry-rails'
    gem 'pry-debugger'
    end

    group :test do
    gem 'capybara'
    gem 'database_cleaner'
    gem 'email_spec'
    end

    group :production do
    gem 'rails_12factor'
    end

    gem 'high_voltage'

    #Linkedin Logins
    gem "linkedin"
    gem "omniauth"
    gem "omniauth-linkedin"

    gem "omniauth-facebook"

    #postgres use hstore in active record
    #gem 'activerecord-postgres-hstore'

    gem 'state_machine'
    gem "ruby-graphviz"


    #payments
    #gem 'stripe',:git => 'https://github.com/stripe/stripe-ruby'

    #gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails', :github => 'anjlab/bootstrap-rails'

    gem 'newrelic_rpm'

    gem 'pgbackups-archive'

    gem 'pg_search'

    gem 'acts-as-taggable-on'

    #gem 'activeadmin' , github: 'gregbell/active_admin'
    gem "activeadmin", git: "https://github.com/gregbell/active_admin"

    gem 'kaminari'
    gem 'bootstrap-slider-rails'
    gem 'bootstrap-sass', '~> 3.1.0'

    最佳答案

    安装 Bootstrap Gem

    1.) 添加 Bootstrap gem :

    gem 'bootstrap-sass'

    2.) 了解 Application.css 文件 app/assets/stylesheets/application.css
    Application.css 获取您的 /stylesheets 中的所有其他文件目录并在您运行应用程序时将它们组合起来。

    3.) 创建一个新的 SCSS 文件 (app/assets/stylesheets/bootstrap_and_customization.css.scss)
    @import 'bootstrap';

    4.) 需要 Bootstrap 的 JavaScript
    ...
    //= require jquery
    //= require jquery_ujs
    //= require bootstrap <--
    //= require turbolinks
    //= require_tree .

    5.) Rails Assets
    group :production do
    gem 'rails_12factor'
    end

    6.) 捆绑安装和重启服务器

    应该就是这样!

    关于ruby-on-rails - Rails 4 + bootstrap 设置 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21519040/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com