Breaking Cloudinary after Rails 6.1 upgrade - ruby-on-rails-6

I upgraded to Rails 6.1, which broke my Cloudinary.
Whenever I go to an instance that has a photo attached, I now get this:
undefined method `service_name' for #<ActiveStorage::Blob:0x00007fb4b1c6de88>
Did you mean? service
Any idea how to fix it?

Running rails active_storage:update solved my problem.
I had already run rails app:update, which created the following migration: AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId
But after running rails active_storage:update I got two extra migrations:
AddServiceNameToActiveStorageBlobs & CreateActiveStorageVariantRecords.

I think this is similar to the issue in another SO topic.
The accepted answer was to run
rails active_storage:update
rails db:migrate

Related

Rails::SourceAnnotationExtractor is not a class/module (TypeError)

I am trying to run my ruby on rails project with version 6 but it does not leave me, I updated it from version 5.2.3 to the most recent one and it sent me that error
This is happening because of an internal change in Rails https://github.com/rails/rails/pull/32065
Please check what gem are you using that is causing this error? Gems like rspec-rails, haml-rails have released updated versions which fix this issue. Rails codebase will also get a fix for this based on this comment: https://github.com/rails/rails/issues/36313#issuecomment-496842892

SCSS/CSS doesn't load with webpack

I must update legacy code of a Rails app but i don't know why the Front is not display correctly and page loading is very slow,
I can't contact the past developers
I got the code from heroku and it works well in production but not in development environment
When i launched the app for the first time i had this error
Webpacker::Manifest::MissingEntryError
And i fix it with
yarn install
I never used webpacker before in my Rails projects, i tried many things to fix it but it doesnt work and i don't know what is the way to lauch a Rails app correctly
UPDATE
I re installed webpacker on my environment and now the server compile with webpack but i got error about a JS library
ERROR in ./app/javascript/packs/landing.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'babel-preset-env' from (repository path)
I can't comment yet so I have to create an answer to help you. Your CSS doesn't seem to be compiled in development environment or the CSS files are not imported somehow.
There can be several issues for that. Do you have any errors in your terminal ? Is your webpack.yml well configured for development ?
development:
<<: *default
compile: true

Rails Spring breaking generators

I'm setting up my first Rails 4.1 app, which comes with Spring, their new preloader. When I try to install Devise using their generator ($ rails generate devise:install), the command line just hangs and nothing gets generated.
If I remove Spring from the gem file and try again, the Devise generator works.
Anyone have any insight?
Check directories of some other projects that you were working on at that time, chances are that the generated files ended up there.
spring seems to get confused when you work with more than one rails app at a time. That's probably what caused your problem
spring runs as a server and keeps a rails environment loaded. I think what happens is that if you work with more than one project at a time then spring system seems to get confused and uses wrong environment.
I have had a situation where I was running rails g ... in one project and the files were getting generated in another project. What was crazy was that I kept renaming and moving that other folder, and still the generator kept putting the files in that folder. As if spring had latched on the the inode of that folder.
Try DISABLE_SPRING=1 rails g devise:install
or ps aux |grep spring and kill all the processes you see and then run rails g devise:install
We are taking out spring from the Gemfile for now while this broken behavior persists, and in the future use rails new --skip-spring
If you want to keep using spring, then try following these rules
Use new shells for each new project
Use a new directory name for each new project (If you do rails new blog, work on it, then mv blog blog.old and rails new blog again, it might not work.
From time to time keep on killing all the spring servers, for safety's (and sanity's) sake.
You can disable spring for any $ rails command by passing the environment variable DISABLE_SPRING=1.
$ DISABLE_SPRING=1 rails generate devise:install
Alternatively, you can try $ spring stop to spin down the spring processes. Running $ rails generate afterwards will spin up a new spring process, which might solve the temporary issue.
There is same problem on rails 5.1.4 for responders gem
I listed solutions along with previous ones:
close terminal and open new one
run command with DISABLE_SPRING=1 bundle exec rails generate responders:install
or export it as environment variable
export DISABLE_SPRING=1
kill running spring process for your app
ps ax | grep spring | grep YOUR_APP_NAME | cut -f1 -d' ' | xargs kill
This is an old post, but i think my experience might help someone...
rails 5.0.1
I was facing same issue after i messed up some devise generated files(i am new to rails and learning) and than i tried rails destroy devise model and i was stuck, tried many time and nothing worked.
Googled, got here, tried excluding spring gems, and it worked, again added spring gems, and devise was again stuck on everything.
I just closed the terminal and opened new one, and it worked.

Temporary scaffolding on rails 3

I'm new to rails and I'm actually reading a tutorial on it but unfortunately it's a very old one (2007). They talk about temporary scaffolding which is a one-line addition to a controller for example:
class StoryController < ApplicationController
scaffold :story
end
I tried it in my project but I'be got this error:
Routing Error
No route matches [GET] "/story"
Try running rake routes for more information on available routes.
I thought maybe it's because I'm running a different rails version, maybe the syntax have changed... So my question is how do we perform temporary scaffolding on rails 3.
I previously had to set config.assets.enabled to false because I had a route error.
I'm running under:
Rails 3.2.13
Windows 8 pro 32-bits
I'm very surprised to see this, because I wasn't around when Rails had this scaffold method you show. I've never heard of it before.
I searched the API documentation (and Rails source) and there is nothing like this now. Instead, there is the rails generate scaffold command. You can find more information at http://guides.rubyonrails.org/command_line.html.
As a suggestion: If you want to use a version of Rails from 2007, the tutorial you have now is fine. If you want to use a modern version, find a modern tutorial. The Ruby on Rails Guides site is good.

Error after upgrading Flex SDK: "{ expected "

After upgrading the Flex SDK from 3.1 to any newer version of the SDK and trying to compile an existing project, the following error appears in the Problems pane:
Description: { expected
Resource: (shows project name, not a specific file)
Location: line 15
Any ideas how to solve this or where to start the bug hunt?
It looks like the problem is in the ...sdks/3.3.0/frameworks/libs/player/10/playerglobal.swc file, but I'm certainly not sure.
I've had this happen (among others). Never got to the bottom of it. In the end I migrated my code files to a new project. There are some pretty nasty bugs in FlexBuilder, especially when working on 64bit windows.
Have you tried to do a clean on the project? You didn't mention this but I assume that the project compiles fine under 3.1? If you create a new project does it compile cleanly (if not, it may mean that you have a bad download of the SDK and need to get a new copy.)
The problem was solved by removing halo.swc from libraries. Copying halo.swc to the project was suggested by an online tutorial (which I cannot find right now).

Resources