I'm not sure why, but whenever I run rake assets:precompile, application.js doesn't get compiled. I get a "application.js isn't precompiled" error in production mode.
Here is my Gemfile if it means anything:
source 'http://rubygems.org'
gem 'rails', '3.1.1'
gem 'eventmachine', '1.0.0.beta.4.1'
gem 'thin'
gem 'mysql'
gem 'win32-open3-19'
gem 'paperclip', '2.3.8'
#gem 'jammit'
gem 'jsmin'
gem 'will_paginate'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
I made a new rails app and tested the rake assets:precompile and it's working. The only difference between the two apps in terms of relevant files would be what gems I have installed. "application.js" is the same between both apps...as are the environment.rb files.
Also of note...when I include a random .js file in my assets/javascripts directory and use "javascript_include_tag :application", one of the resulting URLs in dev mode look like so: /assets/../javascripts/anytimec.js?body=1 and they obviously fail with 404. However the application.js file is referenced correctly.
UPDATE:
Looking into what Sprockets generates I've noticed that the "logical path" uses "../javascripts" in the location. I tested this by looking at the dump of asset_paths.asset_for('application','js') and asset_paths.asset_for('anytimec','js') respectively. I've also compared those dumps to the same files from a fresh application. The fresh application does NOT prepend the "../javascripts" to the location whereas my current app DOES. It doesn't do this to the CSS files or anything else...just javascript. This is most definitely alluding to the core problem but I don't know where to go from here.
After discovering that it had to do with Sprockets failing when reading a folder specifically called "java" in the assets folder, I renamed it to "applets" and it started working.
See this post for the answer.
Related
I have generated a basic web app using Rails 4.1.4/Ember.js and everything works as expected, but every time I run 'bundle install' etc. it creates a new (empty) folder in my root directory of the form 'bundler20140904-22128-1jtt7b7' (the random digits at the end change each time). They pile up so deleting them is getting kind of annoying, but does anyone have any ideas why this could be happening??. I couldn't find any info via Google, but I was consulting this tutorial if that helps. I'm running CentOS 6.5 with RVM and I have no idea which files are relevant but here's my application.rb:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module MyProject
class Application < Rails::Application
end
end
config.ru:
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/ra
ils/spring
gem 'spring', group: :development
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
#EMBER
gem 'ember-rails', git: 'git://github.com/emberjs/ember-rails.git'
If you need any more info please let me know. I'd be grateful for any help you can provide!
Hey everyone thanks for the help. I ended up re-generating the app from scratch, and the problem went away. As far as what was causing this, it looks like for some reason the line:
gem 'ember-rails', git: 'git://github.com/emberjs/ember-rails.git'
in my Gemfile was causing problems. I changed it to:
gem 'ember-rails'
and it was fixed.
So in my quest to get a ruby dev environment working, I've ran into an issue that seems...confusing to this ruby noob.
When executing rails server, it starts up as expected, but when you put in localhost:3000 to your standard web browser, it replies the following:
Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile.
Now here's the confusing part. I have sqlite3 installed (the 64 bit version, as that is what I downloaded, and am running a 64 bit OS), as verified by gem query (here's the full list of gems)
Uninstalling and reisntalling didn't do a lick of good for the issue at hand, but it did install without a hitch. Also the gemfile for the project that I'm testing this with is the folliwing
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
As you can see, sqlite3 is specified in the Gemfile quite early on, yet for whatever reason when I try to load the main page, it acts like it's not there.
Particulars for this machine are the following that weren't mentioned earlier in the gems section:
Rails 4
Ruby 2
Windows 7
Anyone ever ran into this before?
I just had this issue too. Go into your Gemfile.lock file and search for the 'sqlite3' entry. You'll note it reads sqlite3 (1.3.8-x86-mingw32).
Change that to sqlite3 (1.3.8-x64-mingw32) and then run the bundle install command and everything should work like normal.
I faced same issue and this seems to be Windows 7 specific Env issue. My problem was resolved with below changes
Go into your Gemfile.lock file and update sqlite3 (1.3.8-x86-mingw32) to sqlite3 (1.3.8-x64-mingw32)
Run bundle install from the project directory. That will update Gemfile.lock. You also have to restart the Rails server.
Also see config/database.yml which specifies which gem to use for the database.
development:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
I'm using the jquery-ui-rails gem to create a slider, however it does not work on a preexisting project for some odd reason. If I create a new project (rails new blog), generate a user scaffold, then add gmaps4rails gem and then jquery-ui-rails gem the map and slider work and appear just fine. However if I open an older project, follow the exact same steps (adding same columns etc), the map will appear fine but the slider will not appear. Does anyone know why this is/how to fix it?
This is my gemfile in case there are any gems that cause conflicts
source 'http://rubygems.org'
gem 'rails', '3.2.8'
gem 'mysql2'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'jquery-ui-rails'
end
gem 'jquery-rails'
gem 'gmaps4rails'
gem 'bcrypt-ruby', :require => "bcrypt"
gem 'mail'
found the issue, after adding the jquery-rails-ui gem you need to run bundle exec rake assets:precompile in the command line for it to work.
It could be that you are including jquery-ui-rails only in the assets group. The gems in the assets group are only used during asset pipeline operations.
Move jquery-ui-rails outside of the assets group, run 'bundle install', and see if it works.
I'd like to now if anybody could help me with my heroku deployement.
I've set up my Rails 3.2 app with the following Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'mongoid'
gem 'bson_ext'
gem 'mongoid_slug'
gem 'heroku'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem "compass", ">= 0.12.alpha"
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
And I have run the rails g mongoid:config command
From the heroku support, I've added the mongolab extension and changed the mongoid.yml evironnement variables to MONGOLAB_URI
When I then deploy the app, it doesn't run on heroku.
I'm not sure what is going on, but i get this error message in the Heroku logs:
WARNING: Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/actionmailer-3.2.0.gemspec'
2012-01-29T19:13:46+00:00 app[web.1]: Could not find activemodel-3.2.0 in any of the sources
here is the full log file:
https://gist.github.com/1700231
has anybody experienced the same issue? I'm not sure if the problem comes from my set up or if I need to add something to rails to work with mongoid?
Cheers.
It's been a bit of pain int the b*tt, but I'm finally there.
http://railsapps.github.com/rails-heroku-tutorial.html
is the right place to go to deplay rails 3.2 on heroku.
This said my head hurt, not too much fun to get so many hurdles when one wants to learn.
Octopress looks fine at the moment I tell you :)
Alright let's keep going
Sprockets seems to make an error in determining the logical_path of my javascript assets (except for application.js). It prepends "../javascripts" to the path and so my references are wrong and the application.js file won't precompile. I'm using Rails Thin server on Windows.
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'eventmachine', '1.0.0.beta.4.1'
gem 'thin'
gem 'mysql'
gem 'win32-open3-19'
gem 'paperclip', '2.3.8'
gem 'jsmin'
gem 'will_paginate'
gem 'jquery-rails'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
I've created a new app and on it's own, there are no problems. It's only when I copy the files from my current app over that the problem starts. I've tried disabling all extraneous gems but the problem persists (leading me to believe it's not a gem that's causing the problem).
Wow. Apparently Sprockets pukes invisible chunks when it finds a folder called "java" under "assets" and simply doesn't process anything else from that point forward for js files. Under /assets I had "images", "javascripts", "java" (for java applets) and "stylesheets". Changing "java" to "applets"
"FIXED"
the problem.