Posts tagged upgrades

All posts

Just fooling around

I’m in full Ruby 3.4 upgrade at work and for the Injectable gem we released as OSS and is now an independent organization.

So my personal site should not fall behind! Upgraded the ruby versions to 3.4.5, started using bundler 2.7 in v4 simulation mode, and threw in a bump to bootstrap 5.3.7.

It’s been weird because since at work we’re using Cursor, it’s been my first time in a while without AI agents suggesting code or being there easily accessible for questions. For a minute there I thought I had forgotten how to do this myself haha. Anyway, added an AI generated Changelog because it’s kinda easy to feed a git log to chatgpt and ask to format it.

Would like to try something different to bootstrap tho.


Site revamp

Some months ago a workmate suggested we upgraded some of our pages from Bootstrap version 3.4 to 4.4. We didn’t do it in the end, since this came up inside a specific project and we didn’t want to fix some other critical pages while doing this upgrade.

Also we had some voices in the team advocating for ditching Bootstrap altogether, so, in the face of several possibilities, inaction took the best of us.

Anyway, while doing this work several differences in the usage of classes in the HTML markup made me curious about Bootstrap 4, so I decided to give it a try on this very site.

This past couple of days I have set this jekyll project to use the latest and greatest from Ruby and Jekyll, removed MaterializeCSS and moved everything to Bootstrap 4. In the meantime, I’ve changed the colorscheme of the site, as well as lots of copy, the layout and navigation (now you get to see my face when you first enter the site!).

I’ve kept everything as vanilla Bootstrap as possible, and it’s fast to use. Looking at the dev tools I see there’s a ton less of CSS than it used to be on previous versions, so that’s a win!



Broken AJAX requests after updating to Rails 2.3.15

After updating Rails to 2.3.15 in a Rails 2.3 app, I found that some AJAX requests were suddenly not only not working properly, but they also were a bit tricky to debug, as they error caused the logged user to be kicked out the app.

The strangest thing was the server log claiming that my current_user was not present after the AJAX call. I needed the current_user to get to get to do the request, so it WAS there in the beginning, but in the response, the current_user ceased to exist, so… what was happening?

Well, it turned out to be that Devise (a way old version of the gem, by the way) was kicking the user out due to the impossibility of checking the CSRF token properly, because it was not being encoded and sent in the AJAX request in the first place.

Solving this is easy, and it is something that should have been done from the start. Working with ‘inherited’ legacy apps sometimes brings this sort of problems in the long run.

  1. Add the csrf_meta_tag line in the header section of your application layout.
  2. Modify your javascript AJAX requests so they send the AUTH_TOKEN encoded along with the rest of the data.

Here are some StackOverflow questions that helped me figure out what was happening and how to solve it: one, two, and three.


Update your Rails NOW *Updated*

It seems that all Rails branches (2.3, 3.0, 3.1 and 3.2) have been updated to fix two severe security issues (first and second). Please refer to the Rails Weblog post for more information and take action ASAP to keep your rails apps secure!

Insight on the bug causing this ‘emergency’: http://www.insinuator.net/2013/01/rails-yaml/

Things to have into account when updating:

Rails 3.0.x apps over Ruby 1.8.x:

Of course, always do this in your dev environment prior to updating your servers to make sure you’re not breaking anything.

  • Update rubygems to 1.8  (if needed) using gem update --system
  • Modify your Gemfile to specify the rails 3.0.19 version. Note: you might have to delete your local Gemfile.lock before to update it.
  • Run bundle.
  • You may need to update or specify the versions of some gems. For example I found that I had the ``factory_girl_rails`` gem on my Gemfile, but its current version doesn't work with Ruby 1.8 anymore, so I had to specify the 1.7.0 version for this gem in order to keep everything working.
  • You might want to use the gem clean command in order to remove the old rails (and other gems) versions once you've ensured that the app works after doing the previous steps. Beware, this might will break dependencies, run bundler afterwards to attempt to fix broken dependencies. Take extra care with your passenger gem, as you won't come across any problem with it until your actually working on your servers.

Rails 2.x apps:

If you don’t have bundler, install rails gem version 2.3.15, and after that, update your app/config/environment.rb file to use rails 2.3.15.

With this version of Rails I’ve come across this warning message when running Webrick or the Rails Console:

NOTE: Gem.source_index is deprecated, use Specification.
It will be removed on or after 2011-11-01.Gem.source_index called from
/Users/meh/.rvm/gems/ruby-1.8.7-p370@project/gems/rails-2.3.15/lib/rails/gem_dependency.rb:78.

It seems that you may solve this by updating your bundler gem (gem update bundler) to the latest version but I found that I had to downgrade the rubygems version in that gemset to version 1.6.2  (gem update --system 1.6.2) to get rid of the message.