Ask for Help
“How do I create a model without a backing store?”
One way to do this is to use the active-form plugin (or here), which lets you create model objects that support
ActiveRecord Validations but are not backed by database table. Not to be confused with the other ActiveForm, which is a DSL for defining XHTML forms with validation.
TODO
“How do I turn an association into an array?”
You can access the underlying array by using .target or .proxy_target. If you want to cause the association to load all it’s data pass any parameter, for example
blog = Blog.find(:first) posts = blog.posts(:force_load)
Interesting Things
- AWS gems log spew and SSL
Noticed that when using the RightScale Amazon Web Services gem that a lot of log output is going to STDOUT. To capture this output specify a logger wherever you create your AWS service object, for example:
development:
RightAws::S3.new(access_key, secret_key, :logger => Logger.new(File.join(File.dirname(__FILE__), '..', '..', 'aws_sqs.log'), 'daily'))
demo/production:
RightAws::S3.new(access_key, secret_key, :logger => Logger.new(File.join(File.dirname(__FILE__), '..', '..', 'aws_sqs.log'), 'monthly'))
To prevent even more warnings from appearing in your log output you can also set the @http.verify_mode as follows:
original:
@http.use_ssl = true
ca_file = get_param(:ca_file)
if ca_file
@http.verify_mode = OpenSSL::SSL::VERIFY_PEER
@http.verify_callback = verifyCallbackProc
@http.ca_file = ca_file
end
patched:
@http.use_ssl = true
ca_file = get_param(:ca_file)
if ca_file
@http.verify_mode = OpenSSL::SSL::VERIFY_PEER
@http.verify_callback = verifyCallbackProc
@http.ca_file = ca_file
else
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
Just to clarify, you can pass any “truthy” parameter to an association method to cause it to be loaded. Passing `false` or `nil` wouldn’t work. Some folks like to pass a symbol (usually of their own devising). I like to pass `true`.
November 24, 2009 at 9:53 pm
What file did you patch for the SSL warnings? I could not find those lines in any file in RightAWS 1.10.0
November 26, 2009 at 3:09 am
Jonathan — Check out the right_http_connection gem. In 1.2.4 you can find the except on line 301 in lib/right_http_connection.rb.
November 28, 2009 at 9:23 am