I am using the fog gem to send carrierwave uploads to an AWS S3 bucket. That seems to be working fine, but when I try to run my cucumber tests I get:
You are using Excon 0.6.6. WebMock supports version >= 0.9.6
I have moved fog out of the test group in the gemfile (it's only in development and production). I've looked around for other people have thing problem, but I haven't been able to find anything.
My goal really would be to not use fog at all in the test suite, but just use the local file system.
It turns out that I was using an old version of fog. I had:
gem 'fog'
In my gemfile when I needed to have:
gem "fog", "~> 1.12.1"
That fixed this problem.
Yep, I was about to chime in and let you know as much. I think a bundle update fog would also do the trick (without needing to lock to anything in particular or change the gemfile). Glad you were able to get yourself back on track so easily though.
Related
Rails server will not start after install of paperclip. I have this error message in the console:
undefined method 'has_attached_file'.
In my Gemfile
gem "paperclip", :git => "http://github.com/thoughtbot/paperclip.git"
I tried this in my config/environments/development.rb
config.gem "paperclip"
and this in my config/application.rb
Paperclip::Railtie.insert
I have ImageMagik installed on my computer (I'm on windows 10). Any clue ?
I had a message in the console after install of paperclip, saying that paperclip is now compatible with aws-sdk >= 2.0.0. So I also set the latest aws-sdk-ruby from github...
EDIT : also tried this after getting the path with the command 'which convert'
Paperclip.options[:command_path] = "/c/Program Files/ImageMagick-7.0.7-Q16/convert"
First thing I'd change is to use a version number instead of getting the package directly from GitHub.
in Gemfile:
Change
gem "paperclip", :git => "http://github.com/thoughtbot/paperclip.git"
To
gem "paperclip", "~> 6.0"
Make sure to run the rails generate paperclip command (example: rails generate paperclip photo image) to add the needed attachment field to your database model schema.
Once you have the attachment field you can use has_attached_file to mount paperclip to that field (example: has_attached_file :image).
And don't forget to restart your server.
P.S: There's no need to use config.gem "paperclip" and Paperclip::Railtie.insert, I wasn't able to find any mention of them in the GitHub Paperclip documentation so I'm sure they are discontinued now as they were used in pre Rails 4 applications.
P.P.S: I would strongly recommend you dual boot to a Unix operating system (be it a Linux distribution or macOS) or use an online IDE such as Cloud9 instead of using Windows. It's simply a bad idea and while working on your project you want to replicate to the smallest detail your production environment.
Try to add
include Paperclip::Glue
to your Model.
I'm all set now. Apparently there was a problem with the database construction. For the rest, everything is well explained on github https://github.com/thoughtbot/paperclip but 1) I was following a tutorial with a few steps missing and 2) there was a specific problem for windows.
Dropping all the tables and migrating again from scratch seems to have solved the very basic problem which caused the error.
Windows users, pay attention to your path setting of the file.exe which has nothing to do with ImageMagik. You can place this file.exe anywhere you want, in my case
Paperclip.options[:command_path] = 'C:\Sites\utils\GnuWin32\bin'
Thanks anyway!
I create rails app deployed on Heroku.
also, exception_notification gem enabled.
when it is on development setup ActionMailer to Gmail,
everything is fine and sends a notification from Gmail address.
but when it comes to production environment on Heroku,
I get following error when server trying to send a email.
ActionView::Template::Error (code converter not found (UTF-8 to UTF-16))
Could anyone tell me what's happening here?
The issue was raised on the main repository (see here), but so far was not addressed.
You might want to take a look at this fork to the exception_notification gem, specifically this commit which tries to deal with the problem:
https://github.com/alanjds/exception_notification/commit/048fc6be972189e62ca3b9453d19233ec5773016
To use this fork I pointed the gem to it, like so:
Gemfile:
gem 'exception_notification', git: 'git://github.com/alanjds/exception_notification.git'
This solved the issue for me.
Quick adjustment to solution by hananamar, otherwise you'll get an error:
gem 'exception_notification', :git => 'git://github.com/alanjds/exception_notification.git', :require => 'exception_notifier'
I know this is an old post but since I got the same issue some days ago, I wanted to share here that I solved it by forcing the latest version of the gem on my Heroku app.
gem 'exception_notification', '3.0.1'
I guess the problem was with version 3.0.0 and it is fixed on 3.0.1.
Still diving into the interesting (but a bit confusing) world of developing my own gem/engine.
I have successfully deployed it to my (private) GitHub account, but as the gem is in continuous development, I don't want to deploy it again and again and then do bundle update, etc., so I found the option to require a gem by specifying a path like this:
gem 'my_gem', path: 'path/to/my/gem'
This works nicely when developing (it even seems to reload changed files from the gem when rails s is running [at least for helpers and views it seems to do it, didn't use controllers and models yet, but hoping this will be the case for them, too], which is niiiice for developing the engine while using it straight away in the host Rails app).
But when deploying to the production server, I'd like to get the gem from github:
gem 'my_gem', git: "git#github.com:my_company/my_gem"
Sadly, bundler doesn't allow to have a gem required more than once (even when they are in separate development/test and production groups), so I'm doing the following:
if File.directory?('../my_gem')
gem 'my_gem', path: '../my_gem'
else
gem 'my_gem', git: "git#github.com:my_company/my_gem.git"
end
This seems to work nicely so far (didn't test deployment using Capistrano yet, though). But it leaves some questions:
1) Is this the "right" way to solve my problem? Seems a bit odd that I didn't find a much simpler way yet, something like:
gem 'my_gem', path: '../my_gem', git: "git#github.com:my_company/my_gem.git"
...where I'd expect bundler to simply try the :path option first, and if it's not available, it's try the :git option. But as far as I see, when doing this, it only uses the :git option.
2) Is it good practice to develop gems like this? I'm extracting some functionality from my host app into an engine, and at the same time, I'm enhancing this functionality. So I have the engine gem loaded within my host app, and from within my host app I change the engine's codes which are (thank God!) reflected within my host app without having to restart the rails server. This feels quite "right", but as there is a dummy Rails app within the created engine, I'm a bit unsure whether I rather should develop my engine's strictly isolated from my host app, or not. I think this is a bit of a philosophical question, but maybe someone has an opinion about it and can post pros and contras?
3) How do I tell Capistrano to always update my own gem to the newest version from GitHub automatically?
You can do
if ENV['RAILS_ENV'] != "development"
gem 'my_gem', git: "git#github.com:my_company/my_gem.git"
else
gem 'my_gem', path: '../my_gem'
end
assuming that RAILS_ENV is being passed into the bundle command (which is so when using capistrano).
To update your gem to the latest, try making a capistrano task that essentially does this
/path/to/bundler update my_gem
I can't really comment on your other points. Just my 2 cents.
I'm trying to get the spree_i18n gem working, but am not quite getting it.
I've added this to the Gemfile:
gem 'spree_i18n', :git => 'git://github.com/spree/spree_i18n.git'
I'm using RVM, so bundle installed it to:
~/.rvm/gems/ruby-1.9.3-p125#spree/bundler/gems/spree_i18n-e5e3e189c843
instead of the usual location at:
~/.rvm/gems/ruby-1.9.3-p125#spree/gems/
so I'm not sure if RVM is doing something weird.
But running any of the rake spree_i18n:xxx commands results in the following error:
'Don't know how to build task 'spree_i18n:new'
I'm guessing it's because the gem isn't getting picked up by rake and the app. I was thinking that the app should have picked up on the .yml translation files from the gem folder so I would not need to copy them over to the main app folder.
As a quick fix, I copied over the .yml files from the gem folder to the app config/locales folder. It works but definitely feels like a hack.
Can someone please point me in the right direction to integrate this gem correctly?
I've also posted the question here, in case, there's additional information that might help to solve this.
https://groups.google.com/forum/?hl=en&fromgroups#!topic/spree-user/6ycWGfm6eTk
Thank you for your time!
see related closed issue on github
https://github.com/spree/spree_i18n/issues/171
This hasn't got anything to do with paperclip, btw.
I've upgraded to rails 3.2 from a early version of rails 3.
I was using the AWS:S3 class to create buckets and what not.
The following code was working inside a model:
AWS::S3::Base.establish_connection!(:access_key_id => ...blah blah blah
I was also requiring the gem in the model like so:
require 'aws/s3'
However now I've upgraded and have ran all the updates on blunder, I'm getting the error:
uninitialized constant AWS::S3::Base
...when trying to establish a connection to S3.
Does anyone know what this is happening and how to fix it. Thanks.
I know you said it doesn't have to do with Paperclip but are you also using Paperclip in addition to the s3 gem in your app? I don't think newer versions of Paperclip depend on the aws-s3 gem anymore and instead depend on the aws-sdk gem.
Try replacing the aws-s3 gem with the aws-sdk gem.