Upgrading to Rails 6.1.6.1 causes Psych::DisallowedClass: Tried to load unspecified class: Symbol

The error occurs due to the following security update in Rails: https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017 The Hash serializer apparently loaded data with YAML.unsafe_load, which now changed to YAML.safe_load. This new method does not handle data types such as Symbol or Time by default for security reasons. The workaround as the announcement suggests is to either migrate the serializer … Read more

Could not open library ‘vips.42’; Could not open library ‘libvips.42.dylib’

If you have this problem on your local machine.. If you have just upgraded from rails 6 to 7, and have config.load_defaults 7.0 set in config/application.rb, then your app will use vips by default. If that’s what you want, just make sure vips is installed locally. You can install it with homebrew (thanks to @timroman … Read more

How do you get the Ruby on Rails generated id of a form element for reference in JavaScript?

I ended up creating a custom form builder to expose the property directly class FormBuilder < ActionView::Helpers::FormBuilder def id_for(method, options={}) InstanceTag.new( object_name, method, self, object ) \ .id_for( options ) end end class InstanceTag < ActionView::Helpers::InstanceTag def id_for( options ) add_default_name_and_id(options) options[‘id’] end end Then set the default form builder ActionView::Base.default_form_builder = FormBuilder

Rails, Mongoid & Unicorn config for Heroku

You dont actually need to do this, so for people coming to view this question see: http://mongoid.org/en/mongoid/docs/rails.html “Unicorn and Passenger When using Unicorn or Passenger, each time a child process is forked when using app preloading or smart spawning, Mongoid will automatically reconnect to the master database. If you are doing this in your application … Read more

minitest, test::unit, and rails

There is a Test::Unit “compatibility” module that comes with Minitest, so that you can (presumably) use your existing Test::Unit tests as-is. This is probably the Test::Unit module you are seeing. As of rails 3.2.3, generator-created tests include rails/test_help which includes test/unit. The test “something” do syntax is a rails extension. It’s defined in ActiveSupport::Testing::Declarative, which … Read more

How to implement a RESTful resource for a state machine or finite automata

The update action (PUT method) is not appropriate because PUT is suppose to be idempotent. The only this would be possible is if the state was sent as part of the representation. This is inconsistet with an “event”. Is this correct? Correct. Since, events aren’t idempotent, then the a POST must be used. But, to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)