Thanks @cricket and @John
@John I generated the code and then added the relationships manually .
Tried all from scratch ..and now it associates well and correctly :)
@Cricket will try both now
Thanks for the help
Karthik
On Fri, Dec 31, 2010 at 4:15 AM, John L confidentia...@gmail.com wrote:
How are you including $user_id? There are more than one approache you can take:
echo $this-Form-hidden('Post.user_id', array('value' =
$this-Session-read('Auth.User.id')));
Or you can add it to the submitted data inside the controller:
if (!empty($this-data))
{
$this-data['Post']['user_id']
Since we both trust the generated code why don't you do the associations
using the bake command also? Much simpler.
I only mention the incorrect names as these were the names indicated in the
first message. It matters.
On Thu, Dec 30, 2010 at 12:03 AM, Karthikeyan P
If the model names are Post and User then the table names should be
'posts' and 'users' lowercased. The field name is 'user_id' not
'UserId'. Model 'Comment' has a 'comments' table, not a 'Comments'
table. You have to respect CakePHP's File and Classname conventions,
see section 2.4.1 in the
John
I think the class name conventions are correct as the code is a generated
one ..I didn't write the code.It was generated by cake bake command .
* Model 'Comment' has a 'comments' table, not a 'Comments'
table. *
I have not defined anywhere as *Comments* Table..I have done as