Using the paperclipdropbox gem for storage of uploads - ruby-on-rails

I have a Rails app that needs to store resumes for job applications. Locally, the attachment works fine using the Paperclip plugin. I would like to store them on production using the paperclipdropbox gem. I did the following :
1) set up paperclip for attachment following the document on github
2) ran the command for installing the dropbox gem, on which paperclipdropbox
gem install dropbox
3) set up paperclipdropbox as per https://github.com/dripster82/paperclipdropbox#readme
My paperclipdropbox.yml file looks like that
development:
dropbox_key: email_for_dropbox_account
dropbox_secret: password_for_dropboxaccount
production:
dropbox_key: email_for_dropbox_account
dropbox_secret: password_for_dropboxaccount
After running
rake paperclipdropbox:authorize
I get the following error :
C:\Sites\appname>rake paperclipdropbox:authorize --trace
rake aborted!
Don't know how to build task 'paperclipdropbox:authorize'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task_
manager.rb:49:in `[]'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:115:in `invoke_task'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:94:in `block (2 levels) in top_level'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:94:in `each'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:94:in `block in top_level'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:133:in `standard_exception_handling'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:88:in `top_level'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:66:in `block in run'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:133:in `standard_exception_handling'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/appli
cation.rb:63:in `run'
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in
`'
C:/RailsInstaller/Ruby1.9.2/bin/rake:19:in `load'
C:/RailsInstaller/Ruby1.9.2/bin/rake:19:in `'
I didn't find much documentation online unfortunately. Any idea of what may be causing the problem ? Do you have any other free alternatives for storage ?

I think you might have installed the gems, but didn't defined them in your Gemfile. Make sure that you have paperclip, dropbox, paperclip-dropbox gem in your Gemfile.
gem 'paperclip'
gem 'dropbox'
gem 'paperclipdropbox'
then run bundle install, and try to run that rake task again. This is because by default Bundler would isolate and make only gems that in your Gemfile to be visible to your Rails application.

You must create the project in dropbox. Here you have the link.
after use rake paperclipdropbox:authorize

Related

No command "rails test" in my Ruby-on-Rails application

I've recently joined a team on a Ruby-on-Rails application, and I try to audit the tests. There were no tests, so I decided to implement them in the app.
After seeing around what was there, I have seen there were no command to run the tests available. I ran the following command:
rails --tasks
In the output, there is no command such as rails test, rails test:system. Surprisingly, I can run the command rails test with success. But the command rails test:system --trace fails with following output:
rails aborted!
Don't know how to build task 'test:system' (see --tasks)
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task_manager.rb:59:in `[]'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:159:in `invoke_task'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/command.rb:48:in `invoke'
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
I have tried running the command in a freshly created app, and I can see the available commands rails test and rails test:system.
rails --tasks
Any idea why the command rails test:system fails? Thanks.
Ruby version: 2.3.3
Rails version: 5.2.0
EDIT:
I'm using MiniTest
To run all specs in a single go:
rspec
To execute a specific test file:
rspec <path to the file> # rspec spec/controllers/mytest_spec.rb
Use --format documentation for a formatted output.
Prepend bundle exec if rspec throws a dependency error.

How to use the attach gem in rails 5

My environment:
Ruby 2.4.1
Rails 5.1.4
I am trying to use the attach gem, written by the person who also wrote this article https://atech.blog/atech/file-attachments-in-rails-tutorial.
When I run the bundle install it installs attach gem, version 1.0.2
Then when I try to run the rake command I get an error saying it does not know how to build the task.
rake attach:install:migrations --trace
rake aborted!
Don't know how to build task 'attach:install:migrations' (see --tasks)
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.0/lib/rake/task_manager.rb:59:in `[]'
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.0/lib/rake/application.rb:159:in `invoke_task'
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.0/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.0/lib/rake/application.rb:116:in `each'
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.0/lib/rake/application.rb:116:in `block in top_level'
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.0/lib/rake/application.rb:125:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.0/lib/rake/application.rb:110:in `top_level'
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.0/lib/rake/application.rb:83:in `block in run'
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.0/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.0/lib/rake/application.rb:80:in `run'
/usr/local/rvm/gems/ruby-2.4.1/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.4.1/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.4.1/bin/rake:23:in `<main>'
/usr/local/rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'
Any ideas on what the error is? I am wondering if I am missing a required gem to make it work. The link to the attach documentation is https://github.com/adamcooke/attach
There are no rake tasks defined in this repo.
After you run bundle install, you can get a list of rake tasks by running rake -P (rake -T shows tasks with descriptions). You'll see that attach:install:migrations is not there.
Why not try using paperclip?

rake db:load doesn't work

I'm totaly noob in Ruby, and I can't execute the command rake db:load. Sorry for stupid question, but I need help.
The same error is thrown on rake db:seed
root#root:/var/www/dir# rake db:load --trace
rake aborted!
Don't know how to build task 'db:load'
/usr/lib/ruby/gems/1.8/gems/rake-10.0.4/lib/rake/task_manager.rb:49:in `[]'
/usr/lib/ruby/gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:142:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:101:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:101:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/usr/lib/ruby/gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:73:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-10.0.4/bin/rake:33
/usr/bin/rake:23:in `load'
/usr/bin/rake:23
There's two issues with this project. First of all it lacks a Javascript runtime. You can solve this by adding
gem 'execjs'
gem 'therubyracer'
to the GemFile and rerunning
bundle install
The second problem is that there is no db:load task specified. Looking at the code you want to use
bundle exec rake db:schema:load
That should work.

"rake adcenter-client" giving error-RoR

I am using adcenter-client gem for using microsoft's adcenter api in my RoR-2.3.8 application.
I am using ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]
After installing the gem adcenter-client -v=7.0.3 I tried to execute rake adcenter-client but I got the following error:
rake aborted!
Don't know how to build task 'adcenter-client'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task_manager.rb:49:in `[]'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:115:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/bin/rake:33
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19
Can anyone please give me some suggestion to solve this error?
You only need to run this rake task if you checkout the code directly. When working with the Gem it is not needed.
Got the solution...
Even it is mentioned in GitHub to run rake adcenter-client, but it doesn't require. Code will work properly without this rake task too.

Deploy error on AppCloud with ruby-debug19 in text, development environments

In EY AppCloud, even when you run in development env, they run bundler --without development and test. My Gemfile contains this
group :test, :development do
gem 'ruby-debug19', :require => 'ruby-debug'
end
and when I deploy I get this error:
Successfully installed engineyard-serverside-1.4.2
1 gem installed
~> Deploying revision a01f92c migrating to new FactoryGirl
~> Pushing code to all servers
~> Starting full deploy
~> Copying to /data/eg/releases/20110821184344
~> Ensuring proper ownership
~> Gemfile detected, bundling gems
~> Symlinking configs
ln: creating symbolic link `/data/eg/releases/20110821184344/config/database.yml': File exists
~> Migrating: cd /data/eg/releases/20110821184344 && PATH=/data/eg/releases/20110821184344/ey_bundler_binstubs:$PATH RAILS_ENV=development RACK_ENV=development MERB_ENV=development rake db:migrate --trace
rake aborted!
no such file to load -- ruby-debug
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
/data/eg/releases/20110821184344/config/application.rb:7:in `<top (required)>'
/data/eg/releases/20110821184344/Rakefile:5:in `require'
/data/eg/releases/20110821184344/Rakefile:5:in `<top (required)>'
/data/eg/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/data/eg/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/data/eg/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/data/eg/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:78:in `block in load_rakefile'
/data/eg/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/data/eg/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/data/eg/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:61:in `block in run'
/data/eg/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/data/eg/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/data/eg/shared/bundled_gems/ruby/1.9.1/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/data/eg/releases/20110821184344/ey_bundler_binstubs/rake:16:in `load'
/data/eg/releases/20110821184344/ey_bundler_binstubs/rake:16:in `<main>'
~> [Attention] Maintenance page still up, consider the following before removing:
* any deploy hooks ran, be careful if they were destructive
* any migrations ran, be careful if they were destructive
* your old code is still symlinked as current
Failed deployment recorded in AppCloud
Deploy failed
If I comment out the gem 'ruby-debug19' line in Gemfile it works. But it should be ignoring that anyway since as mentioned, AppCloud ignores test, development env gems. It works locally in both cases. Can anyone think at all what might cause this?
I believe this is because config/application.rb calls Bundler.require with a few group names, one being Rails.env. You RAILS_ENV on the command line is development, which means Bundler.require is trying to load the development group and require things in it, including ruby-debug. Since the bundle has been installed the development group, it breaks.
Probably best to use development for RAILS_ENV when running your app locally and either staging or production for your app on AppCloud.
AppCloud does not install the 'development' or 'test' groups by default. You would need to configure that in an eydeploy.rb file. You can find documentation about Installation Groups at http://docs.engineyard.com/bundler-tips-for-appcloud.html.

Resources