[dancer-users] Dancer::Plugin::SimpleCRUD and 'add_edit_row_pre_save' hook question

Tappin, Chris (AU - Sydney) ctappin at deloitte.com.au
Wed Jul 16 01:22:15 BST 2014


That's great, thanks very much for your help David!

-----Original Message-----
From: dancer-users-bounces at dancer.pm [mailto:dancer-users-bounces at dancer.pm] On Behalf Of David Precious
Sent: Tuesday, 15 July 2014 11:32 PM
To: dancer-users at dancer.pm
Subject: Re: [dancer-users] Dancer::Plugin::SimpleCRUD and 'add_edit_row_pre_save' hook question

On Tue, 15 Jul 2014 02:26:30 +0000
"Tappin, Chris (AU - Sydney)" <ctappin at deloitte.com.au> wrote:

> Hi Dancer users
> 
> I hope you can help me.  I'm pretty new to Dancer and I'm trying to 
> write a simple web service for note taking.  The SimpleCRUD module 
> looks perfect for my needs, but I need to add a timestamp to the 
> record that SimpleCRUD creates.
> 
> From the documentation I assume the right way to do this is with the 
> 'add_edit_row_pre_save' hook, but the code in that sub doesn't seem to 
> ever get called.

The first and most obvious check is that you have at least version 0.91 of Dancer::Plugin::SimpleCRUD installed - as that's the version the add_edit_row_pre_save hook was first added in.

> simple_crud(
>       record_title => 'Log item',
>       prefix => '/crud',
>       db_table => 'prototype',
>       editable => 1,
> editable_columns => [ qw( UFirstName ULastName Details Type KFirstName 
> KLastName Outcome ) ], add_edit_row_pre_save => sub {
>             my $row = shift;
>             open TESTOUTPUT, ">", "TEST.txt" or die "$!";
>             print TESTOUTPUT "hello";
>             close TESTOUTPUT;
> },
> );


That's not how you use it - it's a Dancer hook registered by the plugin, so you use the normal Dancer hook syntax, e.g.:


hook add_edit_row_pre_save => sub {
    ...
};


> Does anyone have some sample code or tips on how to implement 
> 'add_edit_row_pre_save' that they would be willing to share?  My 
> Googling turned up nothing.

Hmm - looking at the docs, it's not at all clear that they're Dancer hooks and use the normal Dancer syntax.  I'll try to address that!



--
David Precious ("bigpresh") <davidp at preshweb.co.uk>
http://www.preshweb.co.uk/     www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan        www.preshweb.co.uk/github


_______________________________________________
dancer-users mailing list
dancer-users at dancer.pm
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
</PRE>
<p class=MsoNormal><span style='font-size:8.0pt;font-family:"Arial","sans-serif";
color:black'>See more with <a
href="http://www.deloitte.com/view/en_GX/global/index.htm"
target="_blank"><span style='color:#0066CC'>Deloitte</span></a>. </span><span
style='font-size:8.0pt;font-family:"Arial","sans-serif"'><a
href="http://www.deloitte.com/view/en_AU/au/news-research/media-releases/9f68f4021a001210VgnVCM100000ba42f00aRCRD.htm"
target="_blank"><span style='color:#0066CC'>2012 Employer of Choice for Women (EOWA)</span></a> and <a
href="http://www.deloitte.com/view/en_AU/au/about-us/awards/index.htm"target="_blank"><span style='color:#0066CC'>Inclusive Workplace of the Year (AHRI Diversity Awards)</a>. 

</span></o:p></span></p>

<p class=MsoNormal><span style='font-size:8.0pt;font-family:"Arial","sans-serif"'>
This e-mail and any attachments to it are confidential. You must not use, disclose or act on the e-mail if you are not the intended recipient. If you have 

received this e-mail in error, please let us know by contacting the sender and deleting the original e-mail.<br>Liability limited by a scheme approved under Professional Standards Legislation. <br> Deloitte refers to one or more of 

Deloitte Touche Tohmatsu Limited, a UK private company limited by guarantee, and its network of member firms, each of which is a legally separate and 

independent entity. Please see <a href="http://www.deloitte.com/au/about" target="_blank"><span style='color:#0066CC'>www.deloitte.com.au/about</span></a> for a detailed 

description of the legal structure of Deloitte Touche Tohmatsu Limited and its member firms.<br><br>



More information about the dancer-users mailing list