Ok just did that, here's the output:

prjr2009/controllers/users_controller.php (line 88)
id: 2

So the ID is correct, but it's still showing the user with id: 1 ! I'm
starting to think it's mocking me =P


brian-263 wrote:
> 
> 
> Put debug("id: ${id}") in your controller. Maybe it's not what you
> think it is. Do you have a route for this action?
> 
> On Thu, Sep 24, 2009 at 1:38 PM, mig_akira <mig_ak...@hotmail.com> wrote:
>>
>>
>> Ops, sorry, here's the code for views/users/view.ctp
>> [code]
>> <div class="noticias view">
>> <h2><?php  __('User');?></h2>
>> <div id="view_conteudo">
>>        <dl><?php $i = 0; $class = ' class="altrow"';?>
>>                <dt<?php if ($i % 2 == 0) echo $class;?>><?php
>> __('Ativo'); ?></dt>
>>                <dd<?php if ($i++ % 2 == 0) echo $class;?>>
>>                        <?php echo $user['User']['active']; ?>
>>
>>                </dd>
>>                <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name');
>> ?></dt>
>>                <dd<?php if ($i++ % 2 == 0) echo $class;?>>
>>                        <?php echo $user['User']['name']; ?>
>>
>> (and son on)..
>> [/code]
>>
>> the contents are not the same, because it happens for every
>> user...doesn't
>> matter if it's user number 7 or 123...=(
>>
>> I don't get, because all other views for other controllers, such as for
>> groups, are correct and are pretty much similar to the users view!
>>
>>
>>
>> brian-263 wrote:
>>>
>>>
>>> On Mon, Sep 21, 2009 at 4:47 PM, mig_akira <mig_ak...@hotmail.com>
>>> wrote:
>>>>
>>>>
>>>> hello everyone!
>>>>
>>>> I'm building a simple web page, with Auth/ACL and a few members.
>>>>
>>>> Problem is, I baked the admin part of the site, and everything works
>>>> fine
>>>> except for one thing! In my users admin page, I click in "view", but it
>>>> insists in showing the view for the first user (in this case, the
>>>> admin).
>>>>
>>>> In my url, it shows /users/view/7 (number of the user's ID), but it
>>>> shows
>>>> the data for the user with ID == 1.
>>>>
>>>> Funny thing is, if I click EDIT instead of VIEW, it shows the correct
>>>> user!
>>>> (and the URL is /users/edit/7)
>>>>
>>>> Here are the codes for the VIEWS/USERS/INDEX.CTP :
>>>> [code]
>>>> <?php
>>>> $i = 0;
>>>> foreach ($users as $user):
>>>>        $class = null;
>>>>        if ($i++ % 2 == 0) {
>>>>                $class = ' class="altrow"';
>>>>        }
>>>> ?>
>>>>        <tr<?php echo $class;?>>
>>>>                <td>
>>>>                        <?php echo $user['User']['username']; ?>
>>>>                </td>
>>>>                <td>
>>>>                        <?php echo $user['User']['name']; ?>
>>>>                </td>
>>>>                <td>
>>>>                        <?php echo $user['User']['email']; ?>
>>>>                </td>
>>>>                <td class="actions">
>>>>                        <?php echo $html->link(__('View', true),
>>>> array('action'=>'view',
>>>> $user['User']['id'])); ?>
>>>>                        <?php echo $html->link(__('Edit', true),
>>>> array('action'=>'edit',
>>>> $user['User']['id'])); ?>
>>>>                        <?php echo $html->link(__('Delete', true),
>>>> array('action'=>'delete',
>>>> $user['User']['id']), null, sprintf(__('Are you sure you want to delete
>>>> #
>>>> %s?', true), $user['User']['id'])); ?>
>>>>                </td>
>>>>        </tr>
>>>> <?php endforeach; ?>
>>>> [/code]
>>>
>>>
>>> That's the view for index(), not view(). The latter would not have a
>>> foreach loop, as you should only have a single User in your array.
>>>
>>>> And here's for the action view in the users_Controller.php:
>>>> [code]
>>>> function view($id = null) {
>>>>                if (!$id) {
>>>>                        $this->Session->setFlash(__('Invalid User.',
>>>> true));
>>>>                        $this->redirect(array('action'=>'index'));
>>>>                }
>>>>                $this->set('user', $this->User->read(null, $id));
>>>>        }
>>>> [/code]
>>>>
>>>> What could be the problem?
>>>>
>>>
>>> Check that you're looking at the proper view file. Then, add
>>> debug($user). It's possible that the record in the database is the
>>> same for User 1 & 7.
>>>
>>> >
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Problem-viewing-data...-tp25530475p25578012.html
>> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>>
>> >
>>
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Problem-viewing-data...-tp25530475p25612039.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to