...I think that's what's happening anyway.
I'm deploying a Rails app to EC2 with Capistrano. The deployment always succeeds, but even if I've just pushed JS/CSS changes to Git, the assets won't compile the first time. When I kept 5 releases, I had to repeat the deployment until all of the old releases were eventually removed. I reduced it to 3, and then to 1. Now, I see a new version of the JS and CSS after 2 consecutive deployments.
In production there are also multiple application.js and application.css files in the shared/public/assets folder including the latest compiled version. Older versions don't seem to get cleaned unless I run rake assets:clobber. rake assets:clean doesn't remove them. I assume it's okay to have more than one version of an asset as long as the manifest points at the right file.
I'd really like assets to precompile when there are new changes. Any help would be appreciated.
Gemfile
gem 'rails', '4.2.3'
gem 'mysql2'
gem 'haml-rails', '~> 0.9'
gem 'sass-rails', '~> 5.0'
gem 'autoprefixer-rails'
gem 'bootstrap-sass', '~> 3.3.5'
gem 'font-awesome-rails'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'underscore-rails'
gem 'ejs'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development do
gem 'capistrano', '~> 3.4.0'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-rbenv', '~> 2.0'
gem 'capistrano-passenger'
end
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end
Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/rails'
require 'capistrano/passenger'
deploy.rb
set :keep_releases, 1
namespace :deploy do
after :restart, :cleanup, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
...
end
end
end
Capistrano Output
INFO [b2b76675] Running RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.2 ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile as ec2-user#xx.xxx.xxx.xxx
DEBUG [b2b76675] Command: cd /var/www/my-app/releases/20150918071822 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.2 RAILS_ENV=production RBENV_ROOT=~/.rbenv RBENV_VERSION=2.2.2 ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
INFO [b2b76675] Finished in 2.014 seconds with exit status 0 (successful).
Make sure that you are running latest sprockets and sprockets-rails. If you have tmp/cache in linked_dirs, remove it.
If that fixes it and you want the shared cache back, you can try to write a Capistrano task which deletes the contents of tmp/cache/assets at the beginning of deployment.
Related
I installed that gem,when I run
rails g active_scaffold:install
It says
Running via Spring preloader in process 6001
Could not find generator 'scoffold'. Maybe you meant 'scaffold', 'css:scaffold' or 'erb:scaffold'
Run rails generate --help for more options.
gemfile
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', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'active_scaffold', github: 'activescaffold/active_scaffold', branch: 'master'
I found the solution
I changed the steps to install the gem, that steps are
1.Insert the gem in gem file, gem 'active_scaffold' and run bundle install.
2.Run the command "rails g active_scaffold User name:string".
3.In gemfile change gem 'active_scaffold' to "gem 'active_scaffold', github: 'activescaffold/active_scaffold', branch: 'master' " and install the bundle once again.
4.Create a DB by "bundle exec rake db:create".
5.Run "rails g active_scaffold:install".
6.Finally migrate it "rake db:migrate"
I want to manually change everything about the style of spree, I don't want to use overides. I want to be able to get to html.erb and update by hand. I'm on linux and have installed Spree, where are they located? I was told it was under rvm, I dont have anything under rvm
Gemfile
source 'https://rubygems.org'
gem 'spree', '3.0.4', :path => "lib/spree/"
gem 'braintree', '~> 2.48.1'
gem 'rails', '4.2.3'
gem 'pg'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
Create rails app and inside lib folder clone spree
then inside rails app Gemfile add spree with lib folder path
something like
gem 'spree' :path => "/lib/spree"
then follow same proceduer, now if you will change in lib folder spree you can see changes in your app
You can use https://guides.spreecommerce.com/developer/extensions_tutorial.html to create an extension for spree then can make changes by using deface https://guides.spreecommerce.com/developer/deface_overrides_tutorial.html
to override html changes in the theme. You can also use Spree Fancy
as reference.
Hope this solves your issue.
Thank you
I've got a fresh rails application, and I'm trying to use the bootstrap-sass gem. When I add #import "bootstrap"; in a .scss file in my app/assets/stylesheets folder, I get this SASS compilation error:
(Line 1: File to import not found or unreadable: bootstrap.
I've seen that many others have had this error, but everything suggested hasn't worked. I've made sure to reboot the server after running bundle install, I even deleted my entire gemset and started fresh. Still, while following the instructions on the bootstrap-sass github page, I get this error, and I can't figure it out!
Gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0.rc2'
gem 'pg', '~> 0.17.1'
gem 'coffee-rails', '~> 4.0.0'
gem 'sass-rails', '>= 3.2'
gem 'bootstrap-sass', '~> 3.0.3.0'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end
gem 'bcrypt-ruby', '~> 3.0.0'
And the error output:
sass --update '/app_root/app/assets/stylesheets/'
> error /path/to/app_root/app/assets/stylesheets/global.scss (Line 1: >File to >import not found or unreadable: bootstrap.
Load paths:
/path/to/app_root/app/assets/stylesheets
/path/to/app_root/app/assets/stylesheets)
>
Compilation exited abnormally with code 1
I'm thinking there may be an issue with the "Load Paths", but when I open a rails console and check Sass.load_paths, it includes the directory of the bootstrap-sass gem.
Any suggestions would be welcome. I've been trying to deal with this for hours now, to no avail.
Ok, I have no idea why this works, but I've been bashing my head against the problem for so long I no longer care.
I found this tutorial and followed it explicitly (easy, because my app is basically empty) from the start. It uses the rails_layout gem, and, somehow, bootstrap is now working as intended.
Everytime I try and push my project to Heroku by using git push heroku master I get the following response. I have a macbook air OSX-10.8.
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using Bundler version 1.3.2
New app detected loading default bundler cache
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Fetching git://github.com/thomas-mcdonald/bootstrap-sass.git
fatal: Could not parse object '9c6c07f74ff515cf38380b014cfede14a4f0eae4'.
Git error: command `git reset --hard 9c6c07f74ff515cf38380b014cfede14a4f0eae4`
in directory
/tmp/build_260d9aa7-1d8e-4738-b10f- fce9113dd86e/vendor/bundle/ruby/2.0.0/bundler/gems/bootstrap-sass-9c6c07f74ff5
has failed.
If this error persists you could try removing the cache directory
'/tmp/build_260d9aa7-1d8e-4738-b10f-fce9113dd86e/vendor/bundle/ruby/2.0.0/cache/bundler/git/bootstrap-sass-33efd1d8ffb6176fdb805029a30f02a6edfbae2e'
Bundler Output: Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Fetching git://github.com/thomas-mcdonald/bootstrap-sass.git
fatal: Could not parse object '9c6c07f74ff515cf38380b014cfede14a4f0eae4'.
Git error: command `git reset --hard 9c6c07f74ff515cf38380b014cfede14a4f0eae4`
in directory
/tmp/build_260d9aa7-1d8e-4738-b10f-fce9113dd86e/vendor/bundle/ruby/2.0.0/bundler/gems/bootstrap-sass-9c6c07f74ff5
has failed.
If this error persists you could try removing the cache directory
'/tmp/build_260d9aa7-1d8e-4738-b10f-fce9113dd86e/vendor/bundle/ruby/2.0.0/cache/bundler/git/bootstrap-sass-33efd1d8ffb6176fdb805029a30f02a6edfbae2e'
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app
To git#heroku.com:fierce-taiga-8706.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:fierce-taiga-8706.git'
Here is are my git remotes
heroku git#heroku.com:sheltered-crag-6550.git (fetch)
heroku git#heroku.com:sheltered-crag-6550.git (push)
origin git#github.com:TheM00se/Pinteresting.git (fetch)
origin git#github.com:TheM00se/Pinteresting.git (push
Here is my Gemfile
source 'https://rubygems.org'
gem 'rails', '4.0.1'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass', branch: '3'
group :doc do
gem 'sdoc', require: false
end
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
I've been trying to figure out a solution for 2 hours and really I'm not even sure what the problem is .
The problem is with:
gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass', branch: '3'
If you check the link below:
https://github.com/thomas-mcdonald/bootstrap-sass/branches
The branch seems to be deleted, maybe it was merged into the master branch, based on feedback from the OP, anyone using it subsequently should add the below to their Gemfile:
gem 'sass-rails', '>= 3.2' # sass-rails needs to be higher than 3.2
gem 'bootstrap-sass', '~> 3.0.3.0'
I'm having a problem with getting delayed_job to start in the production environment. Everything works as it should in development just using the rake jobs:work command, but after deploying to my server with Capistrano, and hours of failed attempts later, I cannot figure out how to get DJ running.
As it says to do on the github repository for delayed_job, I made sure I bundled the "daemons" gem, and also attempted to start it with the command "bin/delayed_job start" instead of "script/delayed_job start" since I'm on rails 4. I've also ran the required generator "rails generate delayed_job" which did generate this file inside the bin directory of my project:
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize
The error I'm consistently getting is -bash: bin/delayed_job: No such file or directory which I think could be since I'm using rvm.
As for my gemfile, I've included delayed_job_active_record and daemons. At this point I'm completely stumped and out of links to explore.
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
# Rails defaults
gem 'sass-rails', '~> 4.0.0'
gem 'bundler'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
# learn-rails
gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails', :github => 'anjlab/bootstrap-rails'
gem 'figaro'
gem 'gibbon'
gem 'high_voltage'
gem 'simple_form', '>= 3.0.0.rc'
gem 'delayed_job_active_record', '~> 4.0.0'
group :development, :test do
gem 'sqlite3'
gem 'better_errors'
gem 'quiet_assets'
gem 'capistrano', '~> 2.15.5'
gem 'rvm-capistrano'
gem 'rspec-rails'
end
group :test do
gem "factory_girl_rails", "~> 4.0"
gem 'capybara'
gem 'poltergeist'
gem "faker", "~> 1.2.0"
end
group :production do
gem 'unicorn'
gem 'pg'
gem 'daemons'
end
Make sure the first line in bin/delayed_job points to a valid Ruby executable. You're using just ruby which probably can't be resolved. rvm is adding the full path to ruby when you cd into the rails_root directory, but that's not happening when the script is executed. One slightly hacky solution would be to cd into the directory, do a which ruby and write that into bin/delayed_job, such as: #!<path_to_ruby>. No need to call /usr/bin/env since Capistrano is doing this already.