[Catalyst] One controller from other

David Schmidt davewood at gmx.at
Sat Dec 4 19:55:22 GMT 2010


On Sat, Dec 4, 2010 at 4:00 PM, linuxsupport <lin.support at gmail.com> wrote:
> Hi,
>
> How can I access one controller from other?
>
> I have 2 controllers called Myapp::Controller::User and
> Myapp::Controller::Admin
>
> In Myapp::Controller::User I have following method.
>
> sub user_list :Path Args:(0) {
>    some function to display all the users.
> }
>
> Myapp::Controller::Admin has following method
>
> sub users :Path Args(0) {
>   Here I want to display all users by calling Myapp::Controller::User
>   $c->controller('Myapp::Controller::User')->user_list is not working
> }
>
> any suggestion?
>
> Thanks
>
> _______________________________________________
> 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@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>

Don't abuse your Controller as a model.
Controllers ideally only contain logic important for the GUI flow.
Returning a list of users should be provided by a models method.

david



More information about the Catalyst mailing list