簡體   English   中英

Rails4:如何提供gem特定的javascript文件?

[英]Rails4: How to serve gem specific javascript files?

我將一個工作rails應用程序復制到另一個目錄中,並使用重命名Gem重命名它。

大多數rails功能都正常,但我無法提供與gems捆綁的資產,特別是來自bootstrap-slider-rails的js文件

我比較了我的application.rb,Gemfile和application.js,它們在兩個應用程序中是相同的。

我已經嘗試過再次卸載和安裝gem

應用程序之間的簡單比較並不能解決問題。

以下是我在兩個應用中驗證的文件相同:

  1. 的Gemfile
  2. application.rb中
  3. application.html.haml
  4. 的application.js

有什么建議我應該如何調試這個?

謝謝!

只是為了向您顯示問題,請在Rubymine中比較這2張圖片

工作應用: 工作應用程序

非工作應用程序: 非工作應用程序

以下是一些相關文件的外觀:

的application.js 在此輸入圖像描述

application.rb中

require File.expand_path('../boot', __FILE__)

# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"

#if defined?(Bundler)
#  # If you precompile assets before deploying to production, use this line
#  #Bundler.require(*Rails.groups(:assets => %w(development test)))
#  # If you want your assets lazily compiled in production, use this line
#  # Bundler.require(:default, :assets, Rails.env)
#end

# Rails4
Bundler.require(:default, Rails.env)

module Smoothlyhired
  class Application < Rails::Application

    # don't generate RSpec tests for views and helpers
    config.generators do |g|

      g.test_framework :rspec, fixture: true
      g.fixture_replacement :factory_girl, dir: 'spec/factories'


      g.view_specs false
      g.helper_specs false
    end


    config.autoload_paths += %W(#{config.root}/lib)



    config.encoding = "utf-8"

    # Configure sensitive parameters which will be filtered from the log file.
    config.filter_parameters += [:password, :password_confirmation]


    config.active_record.schema_format = :sql



    # Enable the asset pipeline
    config.assets.enabled = true

    # Version of your assets, change this if you want to expire all your assets
    config.assets.version = '1.0'

    #Prevent initializing the application and connecting to db on bootup as required by heroku
    #https://devcenter.heroku.com/articles/rails-asset-pipeline
    # Not required on rails4 anymore
    #config.assets.initialize_on_precompile = false

    #config.action_view.javascript_expansions[:defaults] = %w(jquery.min jquery_ujs)
  end
end

的Gemfile

source 'https://rubygems.org'
ruby '2.1.0'
gem 'rails', '4.0.0'
gem 'sass-rails', '~> 4.0.0'
gem 'coffee-rails', git: 'git://github.com/rails/coffee-rails.git'
gem 'uglifier', '>= 1.0.3'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'font-awesome-sass'
gem 'less-rails'
gem 'therubyracer', :platform=>:ruby
gem 'twitter-bootstrap-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'
  gem 'debugger', '>= 1.6.5'
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 '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 'twitter_bootstrap_form_for'
#gem 'bootstrap_form'
#gem 'formtastic'
gem 'formtastic-bootstrap'
gem 'rename'

嘗試刪除gemfile.lock並再次運行bundle install。

也可參考 SO張貼在復制和部署Rails應用。 如果沒有,則應刪除.git文件並運行git init。

我不是百分百肯定這會解決你的問題,但我懷疑你有寶石問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM