Hi I have a Ruby on Rails 4 application with a Spree Engine.
The problem is that is it quite slow and every time I reload a page it takes a long time to load (9 seconds in the last attempt)
I saw on the spree github page that the issue is known and there is a solution where they suggest to precompile assets with bundle exec rake assets:precompile:nondigest command.
Unfortunately when I run this command the rake is aborted. I have run the command with trace
bundle exec rake assets:precompile:nondigest --trace
rake aborted!
Don't know how to build task 'assets:precompile:nondigest'
/home/luca/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.1/lib/rake/task_manager.rb:49:in []'
/home/luca/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.1/lib/rake/application.rb:148:ininvoke_task'
/home/luca/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.1/lib/rake/application.rb:106:in block (2 levels) in top_level'
/home/luca/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.1/lib/rake/application.rb:106:ineach'
/home/luca/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.1/lib/rake/application.rb:106:in block in top_level'
/home/luca/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.1/lib/rake/application.rb:115:inrun_with_threads'
/home/luca/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.1/lib/rake/application.rb:100:in top_level'
/home/luca/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.1/lib/rake/application.rb:78:inblock in run'
/home/luca/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.1/lib/rake/application.rb:165:in standard_exception_handling'
/home/luca/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.1/lib/rake/application.rb:75:inrun'
/home/luca/.rvm/gems/ruby-2.0.0-p353/gems/rake-10.1.1/bin/rake:33:in <top (required)>'
/home/luca/.rvm/gems/ruby-2.0.0-p353/bin/rake:23:inload'
/home/luca/.rvm/gems/ruby-2.0.0-p353/bin/rake:23:in `'
I suspect that the solution of precompiling assests was optimised for Ruby on Rails 3 and it's not working with Rails 4.
Can you advise on how to resolve this or if you have alternatives to speed up the loading time?
Thanks in advance.
The correct command to run is actually the below and it was run without errors
bundle exec rake assets:precompile RAILS_ENV=development
Speed of loading page seems marginally faster.
WARNING: Using the precompile rake task in development will prevent
any changes to asset files from being automatically loaded in when you
reload the page. You must re-run the precompile task for changes to
become available.**
Rails also provides the following rake task that will delete the entire public/assets directory, this can be helpful to clear out development assets before committing.
rake assets:clean
Related
I would like to do the testfirst.org exercises although can't seem to get to the starting line due to a version issue/lack of knowledge on my part as well..
At the begining you have to run the test $rake
i got following error..
(in /home/arno/learn_ruby)
rake aborted!
Gem::MissingSpecError: Could not find 'rspec' (~> 2) among 94 total
gem(s)
Checked in
'GEM_PATH=/home/arno/.gem/ruby/2.4.0:/home/arno/.rbenv/
versions/2.4.0/lib/ruby/gems/2.4.0', execute `gem env` for more
information
/home/arno/learn_ruby/Rakefile:2:in `<top (required)>'
(See full trace by running task with --trace)
I then tried to uninstall rspec. I then tried to install a version less than 3. That also did not work. Now I have version 2.9 and 3.2 installed but the same error persisted..
I then did bundle install and bundle update...something changed although still not working..
Here is the latest error when i run the test $rake..
(in /home/arno/learn_ruby)
rake aborted!
NoMethodError: undefined method `last_comment' for #
<Rake::Application:0x00564ff13bf4b0>
/home/arno/learn_ruby/Rakefile:8:in `new'
/home/arno/learn_ruby/Rakefile:8:in `<top (required)>'
(See full trace by running task with --trace)
Here is the rakefile..
# This Rakefile has all the right settings to run the tests inside
each lab
gem 'rspec', '~>2'
require 'rspec/core/rake_task'
task :default => :spec
desc "run tests for this lab"
RSpec::Core::RakeTask.new do |task|
lab = Rake.application.original_dir
task.pattern = "#{lab}/*_spec.rb"
task.rspec_opts = [ "-I#{lab}", "-I#{lab}/solution", '-f
documentation', '-r ./rspec_config']
task.verbose = false
end
After 2 days of searching i found a solution from The Odin Project.
They have a Test First - Rspec 3 edition..
If your having the same issue go to their repo https://github.com/TheOdinProject/learn_ruby.
Read through the readme file, fork that repo, clone your version of the repo, cd into it and bundle install..
All works fine now..
I have a ruby gem that adds some default rake tasks. I also have some basic integration tests checking the output of rake -T and rake -AT for each of these tasks.
In order to farm out these tasks from some Ruby source code, I chose to use PTY.spawn and captured the stdout and stderr output to streams.
As you might see here on the Travis build:
Failure/Error: Paint.unpaint(out.read)
Errno::EIO:
Input/output error # io_fread - /dev/pts/1
# ./spec/spec_helper.rb:184:in `read'
# ./spec/spec_helper.rb:184:in `run_command'
# ./spec/rake/test_spec.rb:4:in `block (2 levels) in <top (required)>'
This is one of the first times I've used the Travis CI runner, so I tried manually requiring it to install libreadline too. I've updated bundler, rubygems, and have run this on multiple versions of ruby with the exact same error.
Per the constraints of one of my dependencies, I tested against MRI 2.2, 2.3, and 2.4. All of them failed the same way on travis, but also tried them on my local machine (MacOS) using chruby with no problem.
What am I missing?
I would like to deploy the www/ of my (PhoneGap) app to Heroku. I prefer HAML/SASS/CoffeeScript so I created a Guardfile to automatically generate HTML/CSS/JS and copy from src/ to www/. I added www/ to .gitignore. I would like to deploy to Heroku and have rake assets:precompile generate the 'slug'/www/ directory. I added a Rakefile according to the Guard example
require 'guard'
namespace :assets do
desc "Precompile assets - build the whole app"
task :precompile do
Guard.run_all
end
end
However when I try to run it locally, run_all fails.
C:\Users\Chloe\workspace\TypeFunctions>bundle exec rake assets:precompile
rake aborted!
NoMethodError: undefined method `run_all' for Guard:Module
C:/Users/Chloe/workspace/TypeFunctions/Rakefile:6:in `block (2 levels) in <top (required)>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
How can I fix this? (Or is there a better way?)
I had to add
require 'guard/commander'
(Wiki Source)
and
Guard.setup
despite the wiki explicitly saying # You can omit the call to Guard.setup, Guard.run_all will call Guard.setup under the hood if Guard has not been setuped yet.
And I seem to definitely need bundle exec....
I'm deploying a Rails 4 application using Capistrano 3, to a remote server on digital ocean. I've been debugging the process but hit a wall during a rake: assets precompile task.
The error message is:
rake aborted!
NoMethodError: undefined method `server' for main:Object
/home/user_name/apps/project_name/releases/20151123210909/config/environments/production.rb:1:in `<top (required)>'
The specific code on that line in the production.rb file is:
server '159.203.22.61', user: 'user_name', roles: %w{web app}
I followed this link and setup the production.rb file and the only line I added in that file gave me an error. I've used a bit of Capistrano 2 in a previous project but it looks like Capistrano 3 has a lot of changes and it doesn't quite work like its previous version? I read that the project is deployed after all of the rake tasks are finished so I think the deploy.rb file is not the problem. Any help/suggestion is appreciated.
I am giving Heroku a spin for the first time, but am having quite a bit of difficulty even getting my app to open without crashing. When searching for the answer to this problem, the nice people on stack overflow suggest that I run
heroku run rake db:migrate
However, when I do this I consistently get this error back
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
When I run the trace with it I get back this
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rake/application.rb:598:in `raw_load_rakefile'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rake/application.rb:89:in `block in load_rakefile'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rake/application.rb:160:in `standard_exception_handling'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rake/application.rb:88:in `load_rakefile'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rake/application.rb:72:in `block in run'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rake/application.rb:160:in `standard_exception_handling'
/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/rake/application.rb:70:in `run'
/app/bin/rake:41:in `<main>'
I have been searching for the answer for hours but I cannot seem to find one that solves this problem. It is possible I just do not know where to look. Any sort of leads would be exponentially helpful. Thank you!
EDIT
Steps already taken:
git init
git add .
git commit -m "init"
heroku create
git push heroku master
and this is where I tried to run
heroku open
received an error, and to remedy this tried
heroku run rake bd:migrate
Make sure you can run it locally. cd your project and type:
bundle exec gem list rake
if you can not see it here try adding it to your Gemfile by typeing:
echo "gem 'rake'" >> Gemfile
then bundle && git push heroku master