In response to my recent reply, I fixed my problem with the following
change to the hot-input tag. I realize this probably is not the best fix,
but it does work.
<extend tag="hot-input" attrs="path, method, events, selector" >
<%
attributes['message'] ||= 'Loading...'
ajax_attrs, html_attrs =
attributes.partition_hash(HoboRapidHelper::AJAX_ATTRS)
if @invalid_record && @this.new_record?
default_path = request.path + "/new"
else
default_path = request.path
end
add_data_rapid!(html_attrs, "hot-input", :ajax_attrs => ajax_attrs, :path =>
path || default_path, :method => method || 'GET', :events => events ||
'change', :selector => selector)
%>
<span class="hot-input" param="default" merge-attrs="&html_attrs">
<input merge param />
</span>
</extend>
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.