[Catalyst] Basic CRUD example failing

J. Shirley jshirley at gmail.com
Wed Oct 28 14:10:56 GMT 2009


On Tue, Oct 27, 2009 at 11:06 PM, Jason Dixon <jason at dixongroup.net> wrote:

> On Wed, Oct 28, 2009 at 06:57:25AM +0100, Zbigniew Lukasiak wrote:
> > On Wed, Oct 28, 2009 at 6:07 AM, Jason Dixon <jason at dixongroup.net>
> wrote:
> > > Hi all,
> > >
> > > Learning Catalyst here. ??Following along with the manual and I ran
> into
> > > a weird issue. ??I assume the documentation is right so it must be
> > > something with my installation (Catalyst packages on OpenBSD 4.6).
> > >
> > > Following along with the "SIMPLE DELETE FEATURE" example, I made
> changes
> > > to root/src/books/list.tt2. ??Alas, the uri is not rendering properly.
> > >
> > > <a href=3D"[% c.uri_for(c.controller.action_for('delete'), [book.id])
> %]">Delete</a>
> >
> > I may have not updated my view knowledge - but I would write that as:
> > <a href=3D"[% c.uri_for(c.controller.action_for('delete'), book.id)
> %]">Delete</a>
> >
> > Why did you use the square brackets around 'book.id'?
>
> That's straight out of the example.
>
> http://search.cpan.org/~hkclark/Catalyst-Manual-5.8001/lib/Catalyst/Manua=
l/Tutorial/04_BasicCRUD.pod#___top<http://search.cpan.org/%7Ehkclark/Cataly=
st-Manual-5.8001/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod#___top>
>
> If I remove the square brackets it no longer links as ARRAY (I should
> have mentioned this before), but the action_for() returns empty.  So a
> link now appears as:
>
> http://localhost:3000/books/8
>
> Which of course renders a "Page not found" error.
>
> Thanks,
>
>
This sounds like you didn't properly setup the chain (as listed below the TT
example).

Verify the following two sections are fully complete (in particular, the
method attributes on "sub object"):
 *
http://search.cpan.org/~hkclark/Catalyst-Manual-5.8001/lib/Catalyst/Manual/=
Tutorial/04_BasicCRUD.pod#Add_a_Common_Method_to_Retrieve_a_Book_for_the_Ch=
ain
 *
http://search.cpan.org/~hkclark/Catalyst-Manual-5.8001/lib/Catalyst/Manual/=
Tutorial/04_BasicCRUD.pod#Add_a_Delete_Action_to_the_Controller


PS., the square brackets are to denote "Captures" that are handled by the
Chained dispatch type.  In this example, the URL path is
/object/{capture}/delete.  If you had arguments after delete, they would not
be in the captures array.

[% c.uri_for( c.controller.action_for('delete'), [ book.id ], 'after' ) %]
would give you a URI like:
/object/1/delete/after

Hope this helps you out.

Thanks,
-J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20091028/dabe5=
074/attachment.htm


More information about the Catalyst mailing list