Finally upgrading to the latest juicer, I found my prior hack no longer worked. I decided to revisit my solution and replace it with something more effective. While I still overrode a method, I dispatched the temporary file I was using previously.
Ultimately this ought to be Rack middleware. Perhaps next time.
class JuicerController < [...]
Something I’ve always felt was missing from ActiveRecord is the ability to abstract out presentation logic for attributes. For example, you may want to be able to get at an attribute called full_name, but store the constituent parts, first_name and last_name, in your relational database.
Thankfully, I am not alone. There’s a ticket on [...]
The introduction of the new Rails.public_path setter seems useful only for page caching particulars. If you want to get Mongrel via script/server to serve up static content from an alternate root on request, you actually need to monkey patch your way into the Rack stuff, specifically Rails::Rack::Static.
module Rails
module Rack
[...]
Once in a while, you pull of something quite spectacular. Loading Acrobat Reader inside an Ext.Window is such a feat. It’s the cleanest solution I could come up with that enables a single Rails action to handle the entire PDF creation process without a redirect, keeping a session, or using a GET request. [...]
If you’re running a recent version of Rails, the PostgreSQL ActiveRecord adapter has been updated, requiring an updated Pg driver. If you were previously using putline for doing a PostgreSQL COPY inside of Ruby, you’ll need to change two method calls accordingly if you’re getting an exception:
undefined method `putline’ for #<PGconn:0xb63968e8>
In a migration, I [...]
I spent the past three days evaluating various JavaScript dependency resolution and packaging solutions, predominately on the client side. I didn’t find anything completely enamoring.
My objective is twofold. Maintain JavaScript sources using a file per class policy as a general rule. Serve the actual JavaScript portion of my application to the client [...]
When I have a date that can be nil, I usually end up needing the following code, which I’ve monkey patched into ActiveRecord::Base:
private
def string_to_date(value)
value = case value
when blank? then nil
when Date then value
else
begin
Date.parse(value) rescue nil
rescue
nil
end
end
end
Afterward, I simply use the awesome validates_timeliness plugin with :allow_nil => true.
If you’re managing complex model relationships like I am on the server side, you might find you need to sort on multiple columns to maintain correct ordering or perhaps because Ruby on Rails uses SELECT DISTINCT ON internally which exhibits unpredictable results when combined with PostgreSQL and LIMIT.
Presently, Ext JS will simply send the name [...]
While the JSON support in Rails has improved, at least as of 2.1.0 the serializer doesn’t take into account model overrides of #to_json. Fortunately, a patch has been introduced, although it has been staled out.
Rails 2.3.3 and possibly earlier versions of Rails 2.3 no longer have this issue.
In the meantime, I have been defining [...]