Are you certain that you have at least one row in ingredients_recipes with a recipe_id equal to ... hey, wait a minute--your recipe ID is 0. That's not right at all!
You'll need to clear that up, first. How did you put that recipe data into the DB? If it was through a Cake form, something's likely wrong there. If you used an SQL file to import the data, something might be wrong with your table definition. On Thu, Jan 29, 2009 at 1:11 PM, matth <[email protected]> wrote: > > Sure thing. > > My recipes controller view function: > function view($id = null) > { > $this->set('recipe', $this->Recipe->findById($id)); > > } > > > My recipes/view.ctp debug output: > Array > ( > [Recipe] => Array > ( > [id] => 0 > [created] => 2009-01-21 22:49:23 > [name] => Hot Salad > [author] => Tristero > [description] => > [picture] => > [origin] => > [aka] => > [servings] => > [shelf_life] => > [prep_time] => > [cook_time] => > [ready_in] => > ) > > [Ingredient] => Array > ( > ) > > ) > > > On Jan 29, 11:37 am, Webweave <[email protected]> wrote: >> What are you seeing in the debug data for your Recipe find? >> >> Post the controller code where you do the find, and what the data >> output is, and it will be easier for someone to answer your question. >> >> On Jan 28, 1:29 pm, matth <[email protected]> wrote: >> >> > Thanks for that tidbit about the Ingredient model. >> >> > I gave recursive a shot earlier in the day but that didn't help. At >> > the moment, this is exactly what I'm working with: >> >> > class Recipe extends AppModel >> > { >> > var $name = 'Recipe'; >> > var $primaryKey = 'id'; >> > var $recursive = 2; >> >> > var $hasAndBelongsToMany = array( >> > 'Ingredient' => array( >> > 'className' => 'Ingredient', >> > 'joinTable' => 'ingredients_recipes', >> > 'foreignKey' => 'recipe_id', >> > 'associationForeignKey' => 'ingredient_id', >> > 'unique' => true, >> > ) >> > ); >> >> > } >> >> > On Jan 28, 3:15 pm, yusuf widi <[email protected]> wrote: >> >> > > no, it is ok if your ingredient model is empty... >> > > try to give recursive parameter with '2' when you use find method. by >> > > default recursive parameter is null. >> >> > > read more about recursive is on the >> > > api.cakephp.orghttp://api.cakephp.org/class/model#method-Modelfind >> >> > > On Thu, Jan 29, 2009 at 4:46 AM, matth <[email protected]> wrote: >> >> > > > Howdy, >> > > > I'm having trouble fully wrapping my head around Cake's models. They >> > > > seem great and I'm really working to figure out how to take advantage >> > > > of all the benefits. >> >> > > > However, I can't quite figure out how to set up my models >> > > > appropriately. For example, I have two models (Recipe and Ingredient) >> > > > and I have defined they following relationship in my Recipe model: >> >> > > > var $hasAndBelongsToMany = array( >> > > > 'Ingredient' => array( >> > > > 'className' => 'Ingredient', >> > > > 'joinTable' => 'ingredients_recipes', >> > > > 'foreignKey' => 'recipe_id', >> > > > 'associationForeignKey' => 'ingredient_id', >> > > > 'unique' => true, >> > > > ) >> > > > ); >> >> > > > But I'm not able to retrieve my ingredients. So what's the deal? Is >> > > > something wrong with my table setup? Do I need to modify my Ingredient >> > > > model (because it's empty)? >> >> > > --http://www.wmonou.com > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
