12 Sep '13, 3am

Use lambdas for Rails 3 Route Constraints | Intridea Blog

I love the new constraints feature of Rails 3 routing. It opens up powerful new avenues for handling certain scenarios before a request is even delivered to the controller. One thing that bugs me, though, is that making a new class for any non-standard request-based constraint is kind of a pain. Rather than this: class SignedInConstraint def self.matches?(request) !request.session[:user_id].blank? end end root :to => 'controller#index', :constraints => SignedInConstraint I'd much rather be able to simply write: root :to => 'controller#index', :constraints => lambda{|req| !req.session[:user_id].blank?} So I mentioned wanting to patch Rails to make this work in Presently and got a brilliantly pragmatic response from fellow Intridean Jeremy McAnally : Jeremy: class Proc; alias :matches? :call; end; # No clue if this would work :P Update: As Jose Valim pointed out, this is act...

Full article: http://www.intridea.com/blog/2011/2/21/use-lambdas-for-ra...

Tweets

#rails good piece of the API to be aware of

api.rubyonrails.org 15 Sep '13, 10am

Optimistic locking allows multiple users to access the same record for edits, and assumes a minimum of conflicts with the ...

To Blog, or Not to Blog

searchenginewatch.com 16 Sep '13, 1pm

A client recently asked me why they need to blog . My first thought on how to respond was probably similar to your reactio...

Route 13 - Bawnogue

dublinbus.ie 12 Sep '13, 6pm

EPiServer CMS Log in to EPiServer CMS 6 Name ­ Password ­ Enable automatic logon to this website If you log in, cookies wi...

Route 40

dublinbus.ie 14 Sep '13, 4pm

EPiServer CMS Log in to EPiServer CMS 6 Name ­ Password ­ Enable automatic logon to this website If you log in, cookies wi...

COLLECTION 252 NOW LAUNCHED! <3 HAPPY SHOPPING!

// Please fill up the form below accurately. Submit only once. // An invoice will be sent to you shortly. // Please check ...

The 3 Step Guest Post Procedure

The 3 Step Guest Post Procedure

searchenginepeople.com 13 Sep '13, 5pm

Do not concern yourself with grammatical mistakes, inappropriate word structure or something related to the caliber of you...

and here's the blog posts and sample app to go ...

pivotallabs.com 12 Sep '13, 9pm

You might call this post Part 2 in a component based architecture series. The first post describes a solution for better o...

I tried to write a serious post and then unicorns got involved....

I tried to write a serious post and then unicor...

skinnyrunner.com 17 Sep '13, 5pm

What I was thinking about on my run this morning… Sometimes the hardest thing is to start again – after an injury, after a...

3 trends to watch out for

3 trends to watch out for

thefinance.sg 15 Sep '13, 6pm

I just returned back to Singapore from the Scandinavian islands not long ago. It has been a wonderful trip personally, cul...

helped well to ensure site runs without hassle ...

railsplayground.com 13 Sep '13, 8am

Developer Hosting Our developer plans offer everything you need to get your Rails, PHP, Perl, or HTML website online quick...