4

I copied a working rails app into a different directory and renamed it using the rename Gem.

Most of the rails functionality works correct, but I am not able to serve assets bundled with gems specifically js files from bootstrap-slider-rails

I have compared my application.rb , Gemfile and application.js and they are the same in both apps.

I have tried uninstalling and installing the gem again

Simple comparison among the apps is not resolving issue.

Here are the files I have verified are same in both apps:

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

Any suggestions how I should debug this ?

Thanks!

Just to show you the issue, compare these 2 images in Rubymine

Working App: Working App

Non working App: Non-working app

Here is how some relevant files look like:

application.js enter image description here

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'
codeObserver
  • 6,521
  • 16
  • 76
  • 121

1 Answers1

1

Try deleting your gemfile.lock and running bundle install again.

Also refer to this SO post on copying and deploying rails apps. If you didn't, you should delete the .git file and run git init.

I'm not 100% sure this will fix your problem, but my suspicion is that you have gem issue.

Community
  • 1
  • 1
Chase
  • 2,748
  • 2
  • 23
  • 32
  • Thanks Chase. I stripped out some more Gems and also rebundled. However that did not help. Also, notice in the image that libraries like jquery, jquery_ujs are also not loaded , through application.js – codeObserver May 13 '14 at 04:03
  • Interesting. Could it be a conflict with activeadmin? There's another SO post about [that](http://stackoverflow.com/questions/10180418/rails-active-admin-css-conflicting-with-twitter-bootstrap-css). – Chase May 13 '14 at 04:35
  • there's also a Chrome extension for Rails [debugging] (https://developers.google.com/chrome-developer-tools/docs/sample-extensions#rails_panel) you also seem to be using the deprecated gem 'anjlab-bootstrap-rails' So you have 2 bootstrap gems, that could cause a problem. You also have formtastic and formtastic-bootstrap which do basically the same thing. – Chase May 13 '14 at 04:53
  • Thanks Chase for following up on comments. Those are the exact gems I took out. Also tried removing active admin with not help. More confusing is that the prev app has the same gem file and the slider etc is still working fine on my machine in the old app – codeObserver May 13 '14 at 05:01
  • No problem. I'm curious to find the solution, seem like it could be something interesting. Maybe gem versions are different? Or perhaps you could use javascript_include_tag to debug it? – Chase May 13 '14 at 13:10
  • I am trying to see if I can increase the bounty to attract more attention. Curious to find the issue , since asset pipeline has always been a hit or miss for me. Btw, I dont even see bootstrap-slider.js files, so wondering if javascript_include_tag will help? – codeObserver May 14 '14 at 06:36