That didn't seem to make a difference...
I closed my other post about cake not letting me make my controller
name plural and reposted it here. I feel like this is a related issue.
I have another model and controller that Event belongsTo and that
seems to work fine. I think there is something wrong with the way I
created something. To make this all work right now I have to call my
model event.php (Event) and my controller
event_controller.php(Event_Controller)
or else cake will tell me the following:

Missing Controller
Error: EventController could not be found.

Error: Create the class EventController below in file: app/
controllers/
event_controller.php

<?php
class EventController extends AppController {

        var $name = 'Event';
}

?>

My Event Model (event.php in /models):
<?php
class Event extends AppModel
{
        var $name = 'Event';
        var $useTable = 'events';
        var $belongsTo = array(
                'GalleryCategory' => array(
                        'className'     =>   'GalleryCategory',
                        'foreignKey' =>      'id',
                        'associationForeignKey' => 'gallery_id',
                        'joinTable' => 'gallery_categories'
                        ),
                'EventCategory' => array(
                        'className'     =>   'EventCategory',
                        'foreignKey' =>      'id',
                        'associationForeignKey' => 'cat_id',
                        'joinTable' => 'event_categories'
                        )
                );
}

?>

Events Controllers (events_controller.php in /controllers):
<?php
class EventsController extends AppController
{
        var $name = 'Events';

        function index()
        {
                $this->set('events', $this->Event->findAll());
        }
}

?>

Look to my previous post for the info on event_categories. I was able
to rename that controller and make it plural; however, it wont let me
with the event controller.
I have made soo many searches on this. Read and reread all the
conventions. I have no idea where to turn.

On Jul 18, 1:07 am, grigri <[EMAIL PROTECTED]> wrote:
> Use a `belongsTo`, not a `hasOne`.
>
> On Jul 18, 3:52 am, Parris <[EMAIL PROTECTED]> wrote:
>
> > So I have a MVC for Events and Event Categories. I am trying to have
> > the name of the category appear on the event page. I am associating
> > events as belonging to event categories with a field called cat_id.
>
> > I am able the retrieve the tables, but for some reason the event
> > category part of the array ends up empty.
>
> > Visually I am trying to make it look something like:
> > Concert: Annual Event
>
> > Where Concert is equal to a cat_name which is associated by cat_id(in
> > the event table) = id(in the event categories table) and Annual Event
> > is the event_title (in the event table). Also the word concert would
> > be linked to show a category view
>
> > Getting data from the event table is no problem.
>
> > I used print_r($event[0]) to show data from the first entry:
> > [code]Array ( [Event] => Array ( [id] => 6 [cat_id] => 1 [gallery_id]
> > => 6 [event_title] => Test [event_date] => 2008-02-09 [event_hour] =>
> > 6 [event_minute] => 0 [event_ampm] => 1 [event_price] => 10.00
> > [event_tickets] => 6 [event_venue] => Venue [event_address] => Address
> > [event_city] => San Jose [event_state] => CA [event_zip] => 95123  )
> > [EventCategory] => Array ( [id] => [cat_name] => [cat_description]
> > => ) ) [/code]
>
> > If you notice the EventCategory part of the array is empty for some
> > reason....
>
> > Event Model:
> > [code]<?php
> > class Event extends AppModel
> > {
> >         var $name = 'Event';
> >         var $hasOne = array(
> >                 'EventCategory' => array(
> >                         'className'     =>   'EventCategory',
> >                         'foreignKey' =>      'id'
> >                         )
> >                 );}
>
> > ?>
> > [/code]
>
> > Event Category Model:
> > [code]
> > <?php
> > class EventCategory extends AppModel
> > {
> >         var $name = 'EventCategory';
> >         var $hasMany = array(
> >                 'Event' => array(
> >                         'className'     =>   'Recipe',
> >                         'order'         =>   'Reciped}
>
> > ?>
> > [/code]
>
> > Event Controller:
> > [code]
> > <?php
> > class EventController extends AppController
> > {
> >         var $name = 'Event';
>
> >         function index()
> >         {
> >                 $this->set('event', $this->Event->findAll());
> >         }}
>
> > ?>
> > [/code]
>
> > Event Category Controller:
> > [code]
> > <?php
> > class EventCategoryController extends AppController
> > {
> >         var $name = 'EventCategory';
>
> >         function index()
> >         {
> >                 $this->set('eventcategory', 
> > $this->EventCategory->findAll());
> >         }}
>
> > ?>
> > [/code]
>
> > Sorry, I know this is a bit lengthy, but I figured I would give a
> > bunch of details rather than be vague. Hope someone can help. Also I
> > don't thing their is a [code] tag here, but it separates things nicely
> > anyways.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to