Notes posted by benissimo

RSS feed
July 12, 2012
1 thank

conditional rescue_from

Would it be possible to do something like:

rescue_from Exception, :with => my_handler, :unless => request.local?
July 10, 2012
0 thanks

Checking content_for

@tordans You asked your question 3 years ago, but in any case, should anyone have that same issue, you can manage that with:

- unless content_for(:footer).blank?
- else
  == render "layouts/footer_big"

content_for(:x) defaults to an empty string, that’s why you need to check for blank? not nil?.

April 14, 2011
0 thanks

Why gsub!

I notice other adapters use sql.sub!, not sql.gsub! and in fact I had trouble with adding the limit parameter to any query involving nested selects. Replacing sql.gsub! with sql.sub! solved that problem for me. Has anyone else had a similar experience with this method?

In other words, replace:

sql.gsub!(/SELECT/i, 'SELECT B.* FROM (SELECT A.*, row_number() over () AS internal$rownum FROM (SELECT')


sql.sub!(/SELECT/i, 'SELECT B.* FROM (SELECT A.*, row_number() over () AS internal$rownum FROM (SELECT')
March 31, 2011 - (>= v3.0.0)
0 thanks

reload is deprecated? what's the new alternative?

What’s the recommended alternative to reload for more recent versions of Rails?