Posts tagged ruby-on-rails

Quickly test a Rails routing table from IRB

:: ruby, ruby-on-rails

By: David

Here is a reminder of two quick ways to check your routes work, directly in IRB. Firstly, what path can you generate from your helpers?

1
2
3
4
irb(main):001:0> app.url_for [Client.last, :manage, Project.last]
  Client Load (2.0ms)  SELECT "clients".* FROM "clients" WHERE "clients"."deleted_at" IS NULL ORDER BY "clients"."id" DESC LIMIT $1  [["LIMIT", 1]]
  Project Load (2.0ms)  SELECT "media_stores".* FROM "media_stores" WHERE "media_stores"."type" = $1 AND "media_stores"."deleted_at" IS NULL ORDER BY "media_stores"."id" DESC LIMIT $2  [["type", "Project"], ["LIMIT", 1]]
=> "http://www.example.com/2-gelato-4-u/manage/projects/7"