New Private Hobo Site Launched - A Note of Thanks.

20 views
Skip to first unread message

paulj...@gmail.com

unread,
Feb 17, 2012, 6:37:09 PM2/17/12
to hobo...@googlegroups.com
I have done a private site for the National Trust for Historic Preservation that collects building history and operational information. It will be used by volunteer data collectors around the country. It's about the 10th app I have built using Hobo in the last 5 years or so.

Hobo is so productive and fun for me. It's really a brilliant tool and I love it.

So, thanks to Tom and the other contributors large and small - your effort is appreciated.

Thanks also to community members who respond to my queries so patiently and with such insight.

Paul Davis

Peter Pavlovich

unread,
Feb 18, 2012, 1:06:39 PM2/18/12
to hobo...@googlegroups.com
Greetings,

I have a question for the experts in the group! Here is the scenario:
  1. Two business object classes: Person and Address
  2. A relationship between these two classes: Person has an address.
  3. A view in which I would like to create a person with an address on the same screen.
  4. Using a custom hobo tag as a reusable address editor and embedding that tag on the person editor screen.
  5. The Address class has a few validations on its attributes (city and state must be filled in)
  6. The Person class has a few validations on its attributes (first and last name must be filled in)
Here is the problem: When I click save person, and I have filled in all the correct information for both the person and the address fields, all saves correctly. If I leave out a required field on the person, all works as expected with the error message and highlighted field. If I leave out a required field on the address, but fill out the person fields correctly, the person saves correctly but the address does not save at all (person saves with no address attached and no address object is saved). I would have expected that the whole save would have failed with an appropriate error message displayed and that the "bad" address object fields would have been highlighted.

What is the correct "hobo" and/or "rails" way of dealing with validation of subordinate or child objects during save and/or update operations? Do I need to do some sort of transaction management or override the "valid?" method on the Person class?

Any assistance would be greatly appreciated!!!!

Regards,

Peter

Matt Jones

unread,
Feb 18, 2012, 8:04:25 PM2/18/12
to hobo...@googlegroups.com

Best place to start is the Rails validation 'validates_associated :address'. Not sure what that will do regarding error messages, though - you may just get a generic "Address must be valid" message instead of the detailed errors.

--Matt Jones

Peter Pavlovich

unread,
Feb 19, 2012, 12:34:08 AM2/19/12
to hobo...@googlegroups.com
Thanks for the help! "validates_associated" worked like a charm. You were right, however, that the resultant error message is too vague to be useful. I will have to investigate fixing this. I saw a post from Ryan Heath that gives me a good starting point: http://rpheath.com/posts/412-a-better-validates-associated. I am not sure why this has not been implemented/included in official rails. Perhaps there is some sort of flag I am missing which would give me the desired behavior?

Regards,

Peter

-- 
Peter Pavlovich

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

Reply all
Reply to author
Forward
0 new messages