I found the answer to my original question. Too easy as usual. By override
the model's destroy method error messages can simply be added to the object's
error collection and false returned, and AS will display them out of the box.
Michael
On Feb 27, 2011, at 12:16 PM, Michael Latta wrote:
> I found the problem, but am surprised it has not been more common:
>
> Rails 3.0.4 requires CSRF token in the header of any XHR requests. rails.js
> in the jQuery branch does not set this on requests, and jrails.js does not
> set it. The result is that requests are rejected and the session cleared.
>
> The following change to rails.js ajax setup resolves this so long as you have
> the csrf_meta_tag in your header:
>
> beforeSend: function (xhr, settings) {
> xhr.setRequestHeader('X-CSRF-Token',
> $('meta[name="csrf-token"]').attr('content'));
>
> if (settings.dataType === undefined ||
> settings.dataType === 'rails') {
> xhr.setRequestHeader('accept', '*/*;q=0.5, ' +
> settings.accepts.script);
> }
> return fire(element, 'ajax:loading', xhr).result !==
> false;
> },
>
>
>
> Michael
>
>
>
> On Feb 25, 2011, at 9:13 PM, Michael Latta wrote:
>
>> Is there a way to display error messages when a user attempts to delete a
>> record and to abort the delete, or is the only option to disable the delete
>> action? The docs cover overriding the do_delete action, but throwing an
>> exception there only results in a 500 error which is not the user experience
>> I want. I want to tell them WHY they can not delete a row, not just disable
>> the button and leaving them guessing. If I could set the hint text for a
>> delete action that would help, but pop-up text is not seen on a tablet or
>> touch screen phone where there is no hover. Any other suggestions on how to
>> better inform the user on why a record is not deletable is welcome.
>>
>> Michael
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en.