So I have run into a use case where I need to solve a bug that is caused by this behavior. I am using hobo 2.1.1 with ROR 4.0.13 and Ruby 2.0. I have a form that I have extended and overriden certain fields with the hot-input tag to cause ajax updates to other fields. When I call up a new form, ajax updates work fine. When I cause a validation error on a new form, hobo routes to the index page and displays the errors. All hot-input actions are also rendered as calls to the default action, index in this case, instead of new. This then causes subsequent failures on all ajax calls because the form context is now a collection instead of a singleton.
Question...is this just as simple as tweaking the hot-input tag definition (which I recognize is not the best fix)? On Tuesday, August 18, 2009 at 9:49:04 AM UTC-7, Bryan Larsen wrote: > > 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/hobousers. For more options, visit https://groups.google.com/d/optout.
