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
Related
I am having an issue deploying my Ruby project to Heroku. I've searched around but haven't found a solution. My error is this:
remote: Sass::SyntaxError: Invalid CSS after "...able_background": expected ")", was ": #808080,"
remote: (in /tmp/build_4a9e512f14d76b318d2a93f5bcb4db07/app/assets/stylesheets/sass/admintable.scss:2)
remote: /tmp/build_4a9e512f14d76b318d2a93f5bcb4db07/app/assets/stylesheets/sass/admintable.scss:2
My scss code it is referring to is this on the second line:
$admin_table_colors:(
admin_table_background: #808080,
admin_table_header_background: #FF6347,
admin_table_header_font: orange,
admin_table_data_background: #808080
);
My gem file:
source 'https://rubygems.org'
gem 'rails', '4.2'
gem 'bcrypt', '3.1.11'
gem 'sass-rails', '4.0.2'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'devise'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'omniauth'
gem 'omniauth-facebook'
gem 'turbolinks'
gem "pundit"
gem "tzinfo-data"
gem 'lodash-rails'
group :production do
gem 'pg'
end
group :test, :development do
gem "rspec-rails"
gem "capybara"
gem "launchy"
gem "rack_session_access"
gem "selenium-webdriver"
gem "better_errors"
gem "factory_girl_rails"
gem "simplecov"
gem "database_cleaner"
gem "pry"
gem "sqlite3"
gem "guard-rspec", require: false
gem "thin"
gem "dotenv-rails"
end
gem "bootstrap-sass", "~> 3.1.1"
gem "faker"
gem "friendly_id"
in my environments production file i have this set:
config.assets.compile = true
I do not have .css files only .scss. Should I convert them to css and remove my scss files for the deployment? Maybe my versions of the gems are not proper? Any insights to get that error out of the way would be great.
Your error message tells everything. You have a CSS syntax error on line #2 of app/assets/stylesheets/sass/admintable.scss.
Make sure the CSS there is valid. You can probably test locally to validate you've fixed the problem with rails assets:precompile.
try below code:
config/environments/production.rb
config.assets.compile = true
then run command:
RAILS_ENV=production rake assets:clean
RAILS_ENV=production rake assets:precompile
then push all compiles files and menifest file to heroku.
I found a solution to my problem. Although I believe my scss code is correct there was a problem in the precompile part. I had to change my map code in all my scss files one example of this is this code:
$admin_table_colors:(
admin_table_background: #808080,
admin_table_header_background: #FF6347,
admin_table_header_font: orange,
admin_table_data_background: #808080
);
I had to change it to:
$admin_table_colors:(
'admin_table_background' #808080,
'admin_table_header_background' #FF6347,
'admin_table_header_font' orange,
'admin_table_data_background' #808080
);
And then I had to change my map-gets. I had these map gets before:
map-get($map: $admin_table_colors, $key: admin_table_background);
And then changed it to:
map-get($admin_table_colors, 'admin_table_background');
I got it to deploy but however my site does not load and I do not know if that has anything to do with that change or it's something else.
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 new to both Ruby and Ruby on Rails. To begin familiarizing myself with the framework, I am going through One Month Rails. Unfortunately, I have hit a snag. Up until last night, I was able to push my app changes to Heroku. Now, however, whenever I try to push changes through, I get this error.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
couldn't find file 'bootstrap'
This is after bundle install(ing) -> git add . -> git commit -> git push. I have done quite a bit of googling, but just can't seem to figure it out. Any help is much appreciated! Thanks!
I am attaching my Gemfile.
Source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
gem 'jquery-rails'
gem 'devise'
gem 'simple_form'
gem 'protected_attributes'
# Use sqlite3 as the database for Active Record
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development, :test do
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.0'
gem 'bootstrap-sass', '~> 2.3.2.1'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
end
group :doc do
gem 'sdoc', require: false
end
Move out following gems from group :development, :test
gem 'sass-rails', '~> 4.0.0'
gem 'bootstrap-sass', '~> 2.3.2.1'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
Heroku tries to compile files for production, not for development and testing.
Working on a fresh install of rails 3.2.8 and getting an error when compiling after adding Mercury:
SyntaxError: cannot return a value from a constructor: "this.element" in class Button
(in /home/*********/**************/vendor/bundle/ruby/1.8/bundler/gems/mercury-0c048033cd79/app/assets/javascripts/mercury/toolbar.button.js.coffee)
I've successfully installed Mercury using Rails 3.2.3, but haven't been able to figure why this wouldn't be working.
Any ideas?
source 'https://rubygems.org'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem 'bootstrap-sass'
gem 'simple_form'
gem 'json'
gem 'ckeditor'
gem 'mercury-rails', :git => 'https://github.com/jejacks0n/mercury.git'
gem 'jquery-rails'
# gem 'jquery-ui-rails'
gem "paperclip", "~> 2.7"
# To use ActiveModel has_secure_password
gem 'bcrypt-ruby', '~> 3.0.0'
# 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', '0.10.2', :platforms => :ruby
gem 'libv8', '~> 3.3.10'
gem 'execjs'
gem 'uglifier', '>= 1.0.3'
end
https://github.com/jejacks0n/mercury/issues/349
i guess you need to lock into coffeescript 1.4.0
this fixed my issue.
Apparently, there is a fix, which is in the github repo, but not on rubygems, yet. If you don't want to downgrade coffee-script, just specify the repository in the Gemfile:
# Gemfile
# ...
gem 'mercury-rails', git: 'git://github.com/jejacks0n/mercury'
and run bundle update mercury-rails, afterwards. This fixed this problem for me without the need to downgrade coffee-script.
Here's what you actually need to type into your gemfile:
gem 'coffee-script-source', '1.4.0'
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