On Mar 17, 2011, at 12:24 AM, Arthur Baldwin wrote:

> 
> I've read enough about hobo to realize that I would like to modularize a 
> section that will group together the following fields:
> 
> Address
> City
> RegionID (aka State)
> PostalCode
> CountryID
> 
> By modularize I mean something that I can quickly add to any model whether it 
> be Employee, Contact, Customer, Vendor or whatever.
> And I would like this module to include a layout design so that the fields 
> will always be in a typical postal address layout:
> 
> Address
> City, Region  PostalCode
> Country
> 
> Region and Country should be dropdowns.  Eventually I would like to have this 
> module include the ability to verify addresses with the USPS.
> 

For this case, given that you're interested in keeping the data on a particular 
record, you might want to try something like this:

class SampleModel < ActiveRecord::Base

  fields do
    shipping_address_line1 :string
    shipping_address_line2 :string
    shipping_city :string
    shipping_postal_code :string
  end

  belongs_to :shipping_region, :class_name => 'Region'
  belongs_to :shipping_country, :class_name => 'Country'

end

in application.dryml (the formatting sucks, but you get the idea):

<def tag="address-form" params="base">
  <input field="#{base}_address_line1" /><br />
  <input field="#{base}_address_line2" /><br />
  <input field="#{base}_city"/> <input field="#{base}_region" /> <input 
field="#{base}_postal_code" /><br />
  <input field="#{base}_country" />
</def>

In a SampleModel form:

<address-form base="shipping" />

which will generate proper names for the fields given the common prefix. By 
default, the region and country fields will be select-one dropdowns.


> I have called most of the colleges and universities in my area, but nobody 
> offers any classes in hobo or in Ruby on Rails.  Yes, I know about RailsCasts 
> with Ryan Bates, but I need more info that is specific to hobo.

The Rapid Rails with Hobo book is a good place to start, as is the Cookbook 
site (cookbook.hobocentral.net). That said, I'd highly recommend you check out 
things like the Railscasts and the Rails Guides (guides.rubyonrails.org) as 
there are many areas where Hobo simply doesn't add anything to stock Rails 
(caching, callbacks, mailers, etc) and many others where the Hobo methods are 
essentially just providing DRYer boilerplate (about half of what 
model_controller does). It's a lot easier to debug stuff when you've got a 
sense of what's going on underneath the "magic".

I don't know of any formal Hobo training program, although I've helped a 
handful of people over at Barquin get up to speed. Not really "training" as 
much as "working through the tutorials with an experienced dev nearby", though 
- which is pretty much what this list is intended for. I'm also typically on 
Google Talk (same email as this) during business hours, so feel free to bug me 
if there's something that you need a quick answer for.

--Matt Jones




-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to