Hello all,

Due to our goal of API stability, we were unable to come up with a clean
fix for https://hobo.lighthouseapp.com/projects/8324-hobo/tickets/477.

If you use `auto_actions :all, :except => [:new]` in your controller,
Hobo very conveniently places a new-form on the default index page.
This form submits to the create action.   If you have validations on
your model that are violated, Hobo/Rails tries re render the form with
the errors highlighted.  But Hobo 0.8.8 throws an exception trying to do so.

The error occurs because the index page expects a list of records in
this, but all of the other default pages expect 'this' to contain a
single record.

In our solution, we end up calling TWO different controller actions.
The POST calls the #create action.  If #create succeeds, it redirects to
  #show or whatever you've specified in :redirect as it has always done.
   If it fails, it now sets @invalid_record, and then calls #index so
the context may be correctly populated.

This is a general problem.  If your new-page view requires extra data
that your controller puts in @variables, that data will not be available
when your new page is rerendered due to the validation errors.

For 1.0, we're only fixing #index.  We can justify the API change
because #index was broken already.  If you're running into the problem
on other actions you're using custom controller actions anyways.

Post-1.0 we'll probably extend this style of behaviour to all actions.

You can review the patch on github:

http://github.com/tablatom/hobo/commit/2b616a661c75341c8c7378c3be366c2bfb9f9b4d

(A later patch removes the call to ruby-debug.   I did run the
acceptance tests on the code -- the fact that it slipped in is very strange)

Bryan


--~--~---------~--~----~------------~-------~--~----~
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