A long time ago, I tired of going into the irb/console and finding objects/models using the traditional ActiveRecord command
Person.find(15) and now I’m sitting pretty: I can paste in URLs to fetch objects.
# No more of this: => Person.find(15) # instead: => people/15
people/15 is something you’ll copy+paste directly from your browser:
Of course, the url is based on your routing + controllers, so the assumption here is that your routes/controllers map to your active record models. That is, your app is smothered in RESTful love and cuddles.
Not following this? Here’s a video:
How to make this work at home
Thanks goes to…
The some original code for this comes via Mike Clark, who had the idea for syntax
activity(6). This was good.
I previously had another idea to support the syntax
6.to_activity using the RubyGem to_activerecord. I still like the
id.to_class_name structure of this and still use it.
But if I have a perfectly nice looking url sitting in front of me, I can now paste the
class_name/id part into irb and I’m off and running.
Happy New Year.
- MagicCGI shows OpenID user count In the last 20 days, 43 people have used...
- Magic Multi-Connections: A “facility in Rails to talk to more than one database at a time” At this point in time thereâ€™s no facility in Rails...
- [BTS] Magic Models vs ActiveRecords – Efficiency Dr Nic’s Magic Models are magical, that goes without saying....
- [BTS] Magic Models – Class creation [BTS] = Behind the Scenes; also a news-like TV show...