Wolfmans Howlings

A programmers Blog about Programming solutions and a few other issues

Upgrading a Rails 3 app to the latest Rails 8.x

Posted by Jim Morris on 2026-01-20 17:37:59 +0000

I wrote the blog engine this blog is hosted on in 2009, that is 23 years ago as I write this.

It was running a very old version of Ruby (1.8 as I recall) running on a very old version of Ubuntu server, and was ported to Rails3 from merb. It ran all that time, but finally started to show its age (as we all do!).

... Show more ...

Posted in Rails  |  Tags rails,upgrade  |  no comments

How to setup SyntaxHighlighter in Rails 3.1.1

Posted by Jim Morris on 2011-11-12 01:36:29 +0000

Or how to get Rails 3.1.1 assets in vendor/assets to work in production.

... Show more ...

Posted in Rails  |  Tags rails,syntaxhighlighter,assets  |  2 comments

Turn off forgery protection when using caching

Posted by Jim Morris on 2010-12-18 01:04:06 +0000

This one does not seem to be documented, and I just got bit.

After porting my blog engine to Rails 3, I noticed that after a while comments were being rejected with an ActionController::InvalidAuthenticityToken error.

... Show more ...

Posted in Rails  |  Tags rails,authenticity  |  4 comments

Bit Vector Preferences

Posted by Jim Morris on 2007-08-07 23:53:09 +0000

In my latest web project I potentially have a lot of boolean preferences, which I use for enabling or disabling various email notifications to users.

Rather than having to add a migration everytime I want to add a new preference, I thought I would use the composed_of feature in my model and compose the boolean preferences from a bitvector. That way I can simply modify my model to add new preferences rather than add new columns to the database.

... Show more ...

Posted in Rails  |  Tags rails,preferences,composed_of,bitvector  |  2 comments

RSpec testing all actions of a controller

Posted by Jim Morris on 2007-07-28 14:23:07 +0000

A pattern I find very helpful is to find all the actions in a controller and apply a test to all those actions.

For instance this is useful for automatically testing all actions are protected from unauthorized access when using a login system.

... Show more ...

Posted in Rails,RSpec  |  Tags rails,rspec,controllers  |  14 comments

RSpec testing views for escaped HTML

Posted by Jim Morris on 2007-07-06 18:22:57 +0000

For my social networking site snowdogsr.us I decided to escape all user input that gets displayed. I know people like to trick out their profiles with HTML but I want to avoid the various hacks that it allows.

So thinking I had done a good job of using h everywhere I output user input fields, I decided to see if I could actually test this with RSpec view tests.

... Show more ...

Posted in Rails,RSpec  |  Tags rails,rspec,escapinghtml  |  4 comments

REST scaffold_resource security warning

Posted by Jim Morris on 2007-06-26 15:14:04 +0000

This one is so blatantly obvious it bit me in the Butt at 4am this morning when I had to get up and fix it! I am so embarrassed, luckily no private data got out, as no-one has entered any private data yet.

I used the script/generate scaffold_resource to get started, and I left in those nice format.xml things in, thinking I may use them in the future. For the most part this is not a problem, but one of my controllers is a profile table. Much of the data in there is public anyway so no big deal, but a few columns are private data like email, date of birth, phone numbers etc. These are specifically private and not viewable publicly. This is enforced but not having a view that shows any of that stuff to the general public.

... Show more ...

Posted in Rails  |  Tags rails,scaffold_resource  |  4 comments

Developing a social networking site part 3 - tag cloud

Posted by Jim Morris on 2007-06-23 14:02:49 +0000

This is a simple one.

I use the excellent acts_as_taggable plugin, and I wanted to have a tag cloud like everyone does.

... Show more ...

Posted in Rails  |  Tags rails,tagcloud,acts_as_taggable  |  no comments

Developing a social networking site part 2 - rating stars

Posted by Jim Morris on 2007-06-23 13:49:25 +0000

In part 1 I outlined my project to implement snowdogsr.us a social networking site for snow dogs.

I am pleased to announce that version 1 of this site is up, however I had to make some trade-offs to get it up this far. I needed to prioritize my goals and just get the essentials implemented.

... Show more ...

Posted in Rails  |  Tags rails,acts_as_rated,stars,rating  |  11 comments

More JEdit macros for rails

Posted by Jim Morris on 2007-05-31 13:27:46 +0000

I have been using JEdit more and more for my rails development, I have gone back and forth between it and Epsilon, however JEdit is starting to win out. I have upgraded to the latest pre version (4.3pre9).

I have modified a number of macros to do my bidding, and I dumped the Ruby Plugin because I kept running into things it did that I disliked, and it still seems a little buggy.

... Show more ...

Posted in JEdit,Rails  |  Tags rails,editor,jedit,macros  |  4 comments