Sorry, missed send_flash.
It is as follows defined in application.rb controller:
def send_flash(m)
flash[:error] = m
render :update do |page|
page.replace_html active_scaffold_messages_id, :partial =>
'messages'
end
end
On Sep 20, 12:06 am, Swartz <[EMAIL PROTECTED]> wrote:
> Hi otto,
>
> Thanks so much for the help.
> You gave me a giant push in the right direction!
>
> FYI. Two things I discovered.
> 1. send_flash didn't work for me, never heard of it. But AS can
> display one of flash[:error,:warning,:info] hence why I used it.
> 2. The way destroy function is written would cause the "deleted"
> record to be hidden from display by JavaScript call. But it shouldn't
> be if it has children. So to overcome this I modified this further to
> get this:
>
> def destroy
> begin
> super
> rescue ActiveRecord::ReferentialIntegrityProtectionError
> flash[:warning]= 'Unable to delete parent record, when child
> records exist'
> self.successful = false
> end
> end
>
> Note the self.successful = false, which signals that the deletion
> didn't go over well and will not cause the listing to hide still
> perfectly existing record from display.
>
> --
> Swartz
>
> On Sep 5, 8:35 pm, otto <[EMAIL PROTECTED]> wrote:
>
> > Check this code:
> > ...[snip]...
> > def destroy
> > begin
> > super
> > rescue ActiveRecord::ReferentialIntegrityProtectionError
> > send_flash('Imposible borrar porque hay registros relacionados')
> > end
> > end
> > On 7 ago, 14:41, Swartz <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I'm trying to use ActiveScaffold pluging for an admin interface along
> > > with dependent => protect plugin (http://ruido-blanco.net/blog/rails-
> > > dependent-protect-plugin-english/).
>
> > > Depending -> protect plugin's job is to raise an
> > > ActiveRecord::ReferentialIntegrityProtectionError exception whenever I
> > > try to delete a has_many relation which has child records. Example:
>
> > > class Company < ActiveRecord::Base
> > > has_many :employees, :dependent => :protect
> > > end
>
> > > class Employee < ActiveRecord::Base
> > > belongs_to :company
> > > end
>
> > > So that exception should be raised whenever company is being deleted
> > > which has employees associated with it.
> > > It works all fine and dandy if I use my own controller code to edit/
> > > delete records. But since I'm using ActiveScaffold in my controller, I
> > > dont know where to put the rescue clause to catch that exception.
>
> > > Any info would be welcome!
>
> > > Thanks!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---