While building a new docker based staging server for a legacy rails 5.0 app, I started getting the following error:
Clearly the gem is not found on rubygems.org. I recently read on ruby weekly about licencing issue so I need to upgrade the mimemagic gem to make progress.
Our app is using gem paperclip 4.3.7 which depends on mimemagic 0.3.0. So we have no way but to upgrade the paperclip to fix the mimemagic issue. As such paperclip upgrade is easy but can become complicated in some instances but we took a call and decided to upgrade it to the highest version of paperclip 6.1.0 and so the AWS-SDK as well.
I strongly recommed to check the below video found in README showing how to migrate from Paperclip 4.x to 5.x and aws-sdk1.x to 2.x before you migrate the paperclip.
3. Change the paperclip config to add the s3_region
And that worked!
If you are using aws-sdk for uploading files then you need to make changes there as well. We were saving a couple of autogenerated files to S3. Here are simplified snippets of a file upload code before and after migration.
There has already been written about Struct and OpenStruct. But this post focuses on the performance implications of using one over other.
Developers have tendency to use OpenStruct over Struct generally because with OpenStruct, we can arbitrarily set & access attributes. However, in case of Struct, we can only set & access attributes defined at the time of Struct declaration.
You have configured your .env for all common environment variables across environments but they are not loading in production environment.
Here is a catch in the intallation doc.
Here you can see that the document mentions to install the gem only in development and test environments and you just copied and pasted as is in your Gemfile !
The fix is simple. Just remove groups: [:development, :test] or put the dotenv-rails gem outside of all environment like ohter gems required in all environment.
# app/controllers/posts_controller.rbclassPostsController<ApplicationController# for this controller, resource will be load using `id` end
If you try to put load_and_authorize_resource :find_by => :slug in posts_controller.rb hoping it will override the behaviour then you are wrong. It doesn’t work.
To make it working, you need to use :prepend option.