Monday, January 26, 2009

Re: Plugin's model methods is missing

Oh, and don't think that it is enough to only check the "relevant"
places. If you have a model loaded that has an error in the
association this can affect your controller's direct relation to
OrderProduct. This is due to the fact that cake keeps global
references to the Models and the one loaded first takes precedence. If
a "bad version" is called up first then anything after that makes no
diference.

So check every reference to that model while you are at it.

/martin

On Jan 26, 4:13 pm, Martin Westin <martin.westin...@gmail.com> wrote:
> Hi Jaro,
>
> I am pretty sure you have missed the plugin name when "targeting" the
> Model. I have had a number of hard to track "bugs" that were related
> to the "naming" of classes in plugins.
>
> If you do debug($this->OrderProduct) You should see "OrderProduct
> Object..." but you will probably see "ShoppingCartAppModel Object..."
> or something. If so, then you have some problem with targeting the
> class correctly.
>
> Check that it like this in your controller:
> var $uses = array('ShoppingCart.OrderProduct');
>
> Same thing for Model associations. For example:
> var $belongsTo = array(
>     'SomeOtherModel',
>     'OrderProduct'=>array(
>         'className' => 'ShoppingCart.OrderProduct',
>         'counterCache' => true
>     )
> );
>
> Notice how the plugin name needs to be present in the className value
> but should not be there in the "key" for the association.
>
> On Jan 26, 3:50 pm, jaro <november.di...@gmail.com> wrote:
>
> > Hi,
>
> > I have an application created last year using the rc2 release. When I
> > upgraded the core to the stable release, I had a few problems
> > accessing methods in my plugin's model.
>
> > I have an ShoppingCart.OrderProduct model. The OrderProduct model has
> > a function named "was_purchased". It just basically checks if a
> > certain product was purchased by the given user. In my
> > AccountController, it is outside my plugin I called it this way
>
> > $this->OrderProduct->was_purchased($order_id, $user_id);
>
> > The above line gave me the following error:
> > Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
> > check the manual that corresponds to your MySQL server version for the
> > right syntax to use near 'was_purchased' at line 1 [CORE\cake\libs
> > \model\datasources\dbo_source.php, line 514]
> > Query: was_purchased
>
> > In the previous cake version, it works fine. We are actually using it
> > in our production. Any idea? I have checked it with google and the
> > docs but I am probably missing the help I need.
>
> > Cheers,
> > jaro
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: