RightScale Blog

Cloud Management Blog
RightScale 2014 State of the Cloud Report
Cloud Management Blog

Add new comment

I posted this on rubyforge also. Feel free to respond in either place (but please cc: my email if your forum comments here won't do that automagically). -- Hi, Just testing out ActiveSDB. I am wondering if my usage pattern is the most efficient? I setup my table like this: RightAws::ActiveSdb.establish_connection("KEY", "SECRET_KEY", :logger => Merb.logger) Post.create_domain Post.create :title => 'An SDB Blog Title', :body => 'Some really nice body text.', :created_at => Time.now In my posts controller I have something like this (I am using Merb BTW). I did it this way since it was the only way I figured out to get the collection in a way that I could actually access it in my views: app/controllers/posts.rb -- def index @posts = [] Post.find(:all).each do |post| post = post.reload @posts<< post end display @posts end Is this the best way to send a collection of found items to the view? This #reload method is not really clear to me (and feels like something that should be handled by the lib instead of called every time. no?). Also, When accessing this collection from the view it feels very clunky. The strings I stored (see above) are returned (always) as an array. Is this fundamental to SDB? I find I have to do things like this in my view to access an attribute which is not very pretty: post['title'][0] And lastly when accessing an object should'nt I be able to also get it with a symbol like: post[:title][0] This fails with an error (its returns a nil)... Please set me right if I am missing something. :-) Thanks, Glenn
Posted by Glenn Rempe (not verified)   Ι   April 15, 2008   Ι   04:44 PM