Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Basic CRUD example failing

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


jason at dixongroup

Oct 27, 2009, 10:07 PM

Post #1 of 6 (438 views)
Permalink
Basic CRUD example failing

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="[% c.uri_for(c.controller.action_for('delete'), [book.id]) %]">Delete</a>

This ends up with a series of ARRAY values, e.g.:
http://localhost:3000/books/ARRAY(0x88328620)

I'm not sure if this is a problem with my Model (DBIC), Controller or
something else. Any suggestions?

Thanks,

--
Jason Dixon
DixonGroup Consulting
http://www.dixongroup.net/

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


zzbbyy at gmail

Oct 27, 2009, 10:57 PM

Post #2 of 6 (404 views)
Permalink
Re: Basic CRUD example failing [In reply to]

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="[% 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="[% c.uri_for(c.controller.action_for('delete'), book.id) %]">Delete</a>

Why did you use the square brackets around 'book.id'?

--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


jason at dixongroup

Oct 27, 2009, 11:06 PM

Post #3 of 6 (404 views)
Permalink
Re: Basic CRUD example failing [In reply to]

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="[% 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="[% 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/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,

--
Jason Dixon
DixonGroup Consulting
http://www.dixongroup.net/

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


gar at plusiagamma

Oct 28, 2009, 3:36 AM

Post #4 of 6 (398 views)
Permalink
Re: Basic CRUD example failing [In reply to]

Hi guys!

During these days p5-Catalyst-* has been updated on OpenBSD
ports tree (as you know): what version of p5-Catalyst-* are you
using?

I ask that because I've followed all tuts w/ old (5.7..) Catalyst
version on OpenBSD, and it didn't work until I updated it to 5.8
(in particular Catalyst::Model::DBIC::Schema didn't work as it
should be: it didn't create the "Result" subdirectory; and also
following the NOTE for older version didn't work). I solved all
these problems updating to the latest version.

But perhaps, catalyst version is not the problem...

Best regards,
Cesare

On Wed, Oct 28, 2009 at 01:07:02AM -0400, Jason Dixon 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="[% c.uri_for(c.controller.action_for('delete'), [book.id]) %]">Delete</a>
>
> This ends up with a series of ARRAY values, e.g.:
> http://localhost:3000/books/ARRAY(0x88328620)
>
> I'm not sure if this is a problem with my Model (DBIC), Controller or
> something else. Any suggestions?
>
> Thanks,
>
> --
> Jason Dixon
> DixonGroup Consulting
> http://www.dixongroup.net/
>
> _______________________________________________
> List: Catalyst[at]lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


jshirley at gmail

Oct 28, 2009, 7:10 AM

Post #5 of 6 (392 views)
Permalink
Re: Basic CRUD example failing [In reply to]

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="[% 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="[% 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/Manual/Tutorial/04_BasicCRUD.pod#___top<http://search.cpan.org/%7Ehkclark/Catalyst-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_Chain
*
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


jason at dixongroup

Oct 28, 2009, 7:24 AM

Post #6 of 6 (392 views)
Permalink
Re: Basic CRUD example failing [In reply to]

On Wed, Oct 28, 2009 at 07:10:56AM -0700, J. Shirley wrote:
>
> 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_Chain
> *
> http://search.cpan.org/~hkclark/Catalyst-Manual-5.8001/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod#Add_a_Delete_Action_to_the_Controller

Oy vey, I feel stupid. I thought I was at the end of a section already.
Obviously I'm missing the delete action on the controller. I'll test
again later and report back.

Thanks,

--
Jason Dixon
DixonGroup Consulting
http://www.dixongroup.net/

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.