I Love Ruby

Posted by Matt on May 16, 2008

In the application I’m currently developing a User has_many Jobs, and each Job has a bunch of nested resources. The application calls for a Dashboard, filled with the latest changes to any Job the currently logged-in user is assigned to.

Sounds difficult huh?


def self.get_latest_items_for(current_user)
  assigned_job_ids = current_user.jobs.collect(&:id)
  find(:all, :conditions => ["job_id in (?)", assigned_job_ids])
end

In order to get the currently logged-in user’s list I just do:


RecentItem.get_latest_items_for(current_user)

Simple, elegant, understandable, and concise.

Scribd_fu featured!

Posted by Matt on March 26, 2008

Oh man, how awesome is this. Nary two hours after releasing Scribd_fu, it is already featured on Scribd’s Resources page! I hope this will help to drum up usage of Scribd_fu across the Rails community.

A big thanks to Scribd for the nod, and the link!

Scribd_fu is now live! 1

Posted by Matt on March 26, 2008

I’m pleased to announce my latest plugin: Scribd_fu.

What it does:
Scribd_fu hides out in the shadows like a document converting ninja, just waiting to process your data into a convenient Flash format (like YouTube) with the help of the black majick of Scribd.com. Imagine imbedding huge documents right inline with your web UI, no downloading, no necessary programs on the client side to view your data. It’s pretty damned cool, and it works with Attachment_fu!

Full write-up, repository, etc is here

git is so fast

Posted by Matt on March 25, 2008

HOW FAST IS IT?

git is so fast that it makes me feel like I haven’t done much work. I used to wait so long for Subversion to checkin that I felt like I had accomplished something!

Announcing Scribd_fu 2

Posted by Matt on March 24, 2008

I’m more than slightly amused to announce the birth of a new Ruby on Rails plugin, Scribd_fu.

Scribd is basically the YouTube for Documents. It’s super awesome when you have a huge PDF that would take quite a tick to download; with this you can view your document in Flash format online, inline, and quick. Scribd_fu will allow you to seamlessly CRUD any document to a Scribd Document. The aim is to also feature full integration with the venerable Attachment_fu plugin. Scribd is a really great service with a ton of potential. It’s fast and reliable to boot.

If you’re a githubber, click that ‘watch’ tab and we’ll see where this goes!

RESTful_ACL has moved! 3

Posted by Matt on March 16, 2008

RESTful_ACL has moved from Google Code to GitHub! Why the move? Well, it’s basically due to git being the new black, and more fun than Subversion. I’m in the process of migrating all of my repositories.For anyone who hasn’t tried git yet, please do. It’s super simple yet really powerful. You can even import your existing Subversion repos to git by simply doing

git svn clone user@host:/path/to/repo
Try it! It won’t screw your existing SVN repo. Honest.So without further adieu, Here is RESTful_ACL’s new home and for the impatient, you can clone the repo via:
git clone git://github.com/mdarby/restful_acl.git

Ordinalize Date in Rails

Posted by Matt on March 06, 2008

Scratched my head for a tick when I noticed that Ruby’s Date::strftime doesn’t include a ordinal formatting option (eg. “January 1st, 2008”). To get the “st/nd/th/rd” in the formatted output, do this:

date.strftime("%B #{date.day.ordinalize}, %Y")

Hope this helps someone out there!

RESTful_ACL Update 2

Posted by Matt on March 02, 2008

Just a quick note to say that RESTful_ACL has been updated. This latest version supports securing non-CRUD actions. It’s a slight cop out of sorts; essentially if the user in question can read an object, they will also be able to do the non-CRUD action. It’s not the best solution to the problem, but it will work for the moment. Maybe there is a slick way to pass in a function name as a hash/block thing that I’m not sure of. Hrm.

RESTful_Acl Update

Posted by Matt on February 19, 2008

Just a quick update to let you know that RESTful_Acl has been updated. I removed the mapped urls option in favor of manually opting out of the ACL check on actions that are to be public. The full write-up can be found at the usual location. Just a heads up!

RESTful_Acl

Posted by Matt on February 08, 2008

I’d like to announce my very first Ruby on Rails plugin; RESTful_Acl.RESTful_Acl is a simple Access Control Layer for Ruby on Rails, it allows you to restrict access on a fine-grained level to any RESTful MVC stack. While the ACL structure and engine are provided by this plugin, the implementation is fully up to the user. Every application is different and everyone likes to setup their User / Account / Role resources differently; this plugin will allow you to do your thing and keep that thing locked down.The full write up is available here!