Saturday, December 8, 2007

Rails to the rescue

It's good to keep the tools in your box sharp, I'm happy I've been messing with Rails on my own, because I need to knock out a prototype for work really quickly, Rails to the rescue!

A couple notes, NetBeans 6.0 is out, and I highly recommend it as your Rails development environment. I took a few minutes to switch to the new IDE, and it's very smooth. Alas, when I switched, I was having a very hard time getting plug-ins, and getting Rails to upgrade via Gems. I was receiving weird buffer errors. Google to the rescue, there was a simple fix that involved upgrading gems..just run this command:

gem update --system

and you should be in business...thanks to the DRY blog for the heads up! I'm also incorporating the WillPaginate plug-in in this round, and I've got to mash-up with Google maps. I did find a gem for Google maps, we'll see how far I get, but I'll post any findings..


Updates:

Apparently, will_paginate returns nil if your collection is smaller than the per-page. I was having a problem where I was returning an array of results for my 'position log', and it would not show up in the form where I had used

<%=will_paginate @obs_log %>

I'm not sure why, but here's the code for will_paginate..

# Renders Digg-style pagination. (We know you wanna!)
# Returns nil if there is only one page in total (can't paginate that).
#

def will_paginate(entries = @entries, options = {})
#total_pages =

if entries.page_count > 1
renderer = WillPaginate::LinkRenderer.new entries, options, self
links = renderer.items

content_tag :div, links, renderer.html_options
end
end

So this really does me no good, I'm sure I'm missing something obvious, but it should at least render the collection without the paging cruft. I'm just in too much of a hurry, but this was frustrating. I punted and just showed the last 30 or so with a :limit in my find_all.

I want to present a REST-ful interface for my app to accept data from a mobile with a GPS, I ran across this RailsCast on REST, which seems useful...

No comments: