Label References and RESTful Authentication in Rails 2

I’m working on a new project that is using the RESTful Authentication generator with Rails 2. As I started to take advantage of the label references capability in Rails 2, I ran into some problems. The default fixtures provided by RESTful Authentication look like this: quentin: id: 1 login: quentin email: quentin@example.com salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test created_at: aaron: id: 2 login: aaron email: aaron@example.com salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test created_at: The problem is that when you use label references, you cannot specify the id (the framework wants to generate the ID rather than let your DB generate it): quentin_workgroup_1: workgroup: quentin_workgroup user: quentin aaron_workgroup_1: workgroup: aaron_workgroup user: aaron The Fix? Simple – remove the IDs from the generated users.yml and things will work properly.

I’m working on a new project that is using the RESTful Authentication generator with Rails 2. As I started to take advantage of the label references capability in Rails 2, I ran into some problems. The default fixtures provided by RESTful Authentication look like this:

quentin:
id: 1
login: quentin
email: quentin@example.com
salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
created_at: <%= 5.days.ago.to_s :db %>

aaron:
id: 2
login: aaron
email: aaron@example.com
salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
created_at: <%= 1.days.ago.to_s :db %>

The problem is that when you use label references, you cannot specify the id (the framework wants to generate the ID rather than let your DB generate it):

quentin_workgroup_1:
workgroup: quentin_workgroup
user: quentin

aaron_workgroup_1:
workgroup: aaron_workgroup
user: aaron

The Fix? Simple – remove the IDs from the generated users.yml and things will work properly.

James Higginbotham

Founder of LaunchAny and author of Principles of Web API Design. James helps enterprises build API platforms and get them ready for AI.