Ajuda com AuthComponent

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Ajuda com AuthComponent

Vinicius Souza
Hello everyone, I'm having trouble with the authentication system, the scenario is as follows: 
I have a database with two tables (Users and Posts) Posts in have a user-id field. 

My PostsController.php with add () function 
   class PostsController extends AppController {

      public $uses = 'Post';
      public $name = 'Posts';

      public function index()
         $this->set('posts', $this->Post->find('all'));

      public function adicionar()
               $this->Session->setFlash('O post foi adicionado com sucesso!');
               $this->redirect(array('action' => 'index'));
            } else {
               $this->Session->setFlash('O post não foi adicionado. Tente novamente!');

And adicionar.ctp 
  <div class="users form">
<?php echo $this->Form->create('Post'); ?>
echo $this->Form->input('title');
echo $this->Form->input('body');
<?php echo $this->Form->end('CRIAR POST'); ?>
<div class="actions">
<li><?php echo $this->Html->link('Listar', array('action' => 'index')); ?></li>

The problem is that the bank is not slavando logged the user who created the post, tried using the hasOne model but had no luck. 

Can you help me?

Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.