I have a legacy Rails 3.2 app and if I have a JavaScript file at:
app/assets/javascripts/jt.js
I'm able to access it at
https://dev-platform.domain.com/assets/jt
We are using the asset pipeline and I'm not sure why this is available. It seems like something in assets/javascripts or assets/styles will show up. Is this the intended behavior? How can I prevent this?
Here's my Gemfile#assets
group :assets do
gem 'coffee-rails', '3.2.2'
gem 'font-awesome-sass', '4.7.0'
gem 'foundation-rails', '6.1.2.0'
gem 'jquery-rails', '3.1.4'
gem 'jquery-ui-rails', '5.0.5'
gem 'sass-rails', '3.2.6'
gem 'turbo-sprockets-rails3', '0.3.14'
gem 'twitter-bootstrap-rails', '2.2.8'
gem 'uglifier', '2.7.2'
end
Related
I was precompiling assets in production environment (apache + passenger) when accidentalment interrupt the process. (many shells open, closing the wrong one)
I run rake again, and the command run until finish. No errors.
The problem is that from these momment the app is not showing more the images and appear broken (image not found).
If i run the app in development environment (rails server) all is ok.
My Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.11'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'mysql2'
gem 'will_paginate'
gem 'simple_form'
gem 'devise'
gem 'ttfunk'
gem 'prawn', :git => "https://github.com/prawnpdf/prawn.git", :ref => '8028ca0cd2'
group :development, :test do
gem 'sqlite3'
gem 'rspec-rails'
gem 'debugger'
end
I am working on ROR app, the app is working fine on local host but when on heroku "http://niveshi.herokuapp.com/portfolio/create" bootstrap is not working and even javascript code is not working. This is my gem file :
source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem "mongoid", "~> 3.1.0"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'less-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'delayed_job_mongoid'
gem 'rb-readline', '~> 0.4.2'
gem 'mechanize'
gem 'debugger'
gem 'twitter-bootstrap-rails'
Any guesses where I am wrong.
Use this on production.rb
config.assets.compile = true
If it is not work Then do the following things.
rake assets:precompile it will generate assets file in your public folder, commit all those file then push the code into heroku server.
Try rake assets:precompile and then upload again to Heroku.
Done , actually this should be out of assets
gem 'sass-rails', '~> 3.1.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'less-rails'
I got the same problem fixed with adding
a. gem 'rails_12factor'
b. bundle exec rake assets:precompile
Up until recently my SaSS has been compiling without a hitch, earlier tonight I started to get the following errors.
I have tried rejigging my Gemfile, but I can not for the live of me workout how to get the files to compile and serve the correct css.
Started GET "/assets/application.css" for 127.0.0.1 at 2013-03-11 21:27:35 +1100
Error compiling asset application.css:
Sass::SyntaxError: File to import not found or unreadable: foundation/common/ratios.
Load paths:
Sass::Rails::Importer(/Users/paulmcguane/Sites/Rails/teammngt/app/assets/stylesheets/app.css.scss)
/Users/paulmcguane/Sites/Rails/teammngt/app/assets/stylesheets
/Users/paulmcguane/.rvm/gems/ruby-1.9.3-p125/gems/compass-0.12.2/frameworks/blueprint/stylesheets
/Users/paulmcguane/.rvm/gems/ruby-1.9.3-p125/gems/compass-0.12.2/frameworks/compass/stylesheets
Compass::SpriteImporter
(in /Users/paulmcguane/Sites/Rails/teammngt/app/assets/stylesheets/app.css.scss)
Served asset /application.css - 500 Internal Server Error
gem file
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'therubyracer', :platform => :ruby
gem 'better_errors'
# Database Gems
gem 'yaml_db'
gem 'thin'
gem 'pg'
gem 'rb-readline'
#Application Processing
gem 'haml'
gem 'json'
gem 'spreadsheet'
gem 'paperclip'
#Phone conversion
gem 'countries'
gem 'phony'
gem 'phony_rails'
#Application required gems
gem 'zurb-foundation'
gem 'twilio-ruby'
gem 'simple-navigation', '~> 3.7.0'
gem 'kaminari'
gem 'client_side_validations'
gem 'event-calendar', :require => 'event_calendar'
gem 'watu_table_builder', :require => 'table_builder'
gem 'best_in_place'
gem 'to_xls', :git => 'https://github.com/dblock/to_xls.git', :branch => 'to-xls-on-models'
#Auth and Management
gem 'devise'
gem 'cancan'
gem 'switch_user'
gem 'paper_trail', '~> 2'
gem 'omniauth-facebook'
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'fb_graph'
#gem 'announcements'
# 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'
# Add these gems
gem 'compass-rails'
gem 'zurb-foundation'
end
gem 'jquery-rails'
gem 'compass'
Judging from the look of your gemfile, you're not specifying a version of zurb-foundation.
The short answer is, specify gem 'zurb-foundation', '= 3.2.5' in your gemfile instead.
Otherwise, if you've run a bundle update anytime recently, your zurb-foundation gem has upgraded to 4.x which does not include a path to foundation/common/ratios anymore.
I was banging my head against the wall with this on Heroku, which I talk about in Avoid a Headache: Precompiling Zurb (Foundation) on Heroku
I'm trying to get carrierwave set up with carrierwave_backgrounder, delayed_job, and fog for storage on AWS S3.
Whenever I try to do anything in the console such as generate controllers, I am getting this error:
ruby-1.9.3-p194/gems/carrierwave_backgrounder-0.0.9/lib/carrierwave_backgrounder.rb:19:in `backend': wrong number of arguments (1 for 0) (ArgumentError)
The culprit seems to be my initializer file, backgrounder.rb, which is copied directly from the carrierwave_backgrounder github.
CarrierWave::Backgrounder.configure do |c|
# :delayed_job, :girl_friday, :sidekiq, :qu, :resque, or :qc
c.backend :delayed_job
end
If I comment that out, my generators and such start working. I set up delayed_job and carrierwave properly I believe. Here's my gemfile as well:
gem 'rails', '3.2.8'
gem 'pg'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'devise'
gem 'delayed_job_active_record'
gem 'carrierwave'
gem 'carrierwave_backgrounder'
gem 'fog'
gem 'rmagick'
Use latest git release for implement this.
Add this in your gemfile:
gem 'carrierwave_backgrounder', :git => "git://github.com/lardawge/carrierwave_backgrounder.git"
I got an issue here. I'm working on an app built with Rails and Backbone. In my development environment, everything's run well, but when I deployed it to the production server, this error showed in my firebug :
TypeError: this._reset is not a function
...;return a.success=function(d,e,f){ba.add?"add":"reset",c&&c(b,...
Could anyone help me on this?
Revision 1
I've precompiled the assets and this is my Gemfile :
source 'https://rubygems.org'
gem 'rails', '3.2.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem 'devise', '1.5.3'
gem 'friendly_id'
gem 'pry'
gem "paperclip", "~> 2.5.0"
gem "kaminari"
#gem "ckeditor", "3.7.0.rc3"
gem "tinymce-rails"
gem "puma"
gem "tlsmail"
gem "rails-erd"
gem "juggernaut"
gem "thin"
#gem 'execjs'
#gem 'therubyracer'
# 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'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
Anyway, I got this new fact. I tried run the app in production mode in my local machine and it ran well, but not in my server. Is there anything that I forgot to install in my server?
It seems that you install backbone manually.
I recommend using something like backbone-rails gem to help integrating rails and backbone gracefully. Something like https://github.com/codebrew/backbone-rails (there are also other gem around, but codebrew implementation is one of the most popular).
This is to ensure consistent dependency across machines.
Don't forget to read about asset pipeline, most of my problem with js and rails in production comes from my lack of understanding regarding rails 3 asset pipeline: http://guides.rubyonrails.org/asset_pipeline.html
And if you're serious about integrating backbone and rails, https://learn.thoughtbot.com/products/1-backbone-js-on-rails is an indispensable resource (at US$ 49)
EDITED:
This is my typical Gemfile when creating backbone.js & rails app:
group :assets do
gem 'haml-rails', '~> 0.3.4'
gem 'sass-rails', '~> 3.2.5'
gem 'bootstrap-sass', '~> 2.0.3.1'
gem 'compass', '~> 0.12.1'
gem 'compass-rails', '~> 1.0.2'
gem 'coffee-rails', '~> 3.2.2'
gem 'jquery-rails', '~> 2.0.2'
gem 'jquery-ui-rails', '~> 1.1.0'
gem 'handlebars_assets', '~> 0.4.4'
gem 'rails-backbone', '~> 0.7.2'
# javascript
gem 'haml_coffee_assets', '~> 1.2.0'
gem 'execjs', '~> 1.4.0'
gem 'therubyracer', '~> 0.10.1'
gem 'uglifier', '~> 1.2.4'
gem 'yajl-ruby', '~> 1.1.0'
end