$this-redirect from a Model?

2008-04-30 Thread avairet
Hi everybody, Is it possible to redirect from the Model? I would like to redirect in an specific action from afterFind() callback... but if I set return false in this callback, like it's possible in beforeSave(), I can't redirect! Thanks by advance for your ideas. BR

Re: $this-redirect from a Model?

2008-04-30 Thread [EMAIL PROTECTED]
You shouldn't redirect from a model as a model should only be dealing with data, not page logic. You should be doing the redirect in your controller. What are you redirecting for anyway? If you redirect after finding data, you'll lose that data and have to find again. On Apr 30, 11:36 am

Re: $this-redirect from a Model?

2008-04-30 Thread avairet
Hi Clark, Thank you for answer. I don't redirect after find, it's an error in my first post. I would like to redirect after save! I know it's a bad idea to redirect from Model, but I'm looking for a solution to stop action after a record save, like the return false in before Save. In fact

Re: $this-redirect from a Model?

2008-04-30 Thread Chris Hartjes
On Wed, Apr 30, 2008 at 11:53 AM, avairet [EMAIL PROTECTED] wrote: In fact, in my Model::afterSave, I do a move_uploaded_file() and if this move doesn't work, I would like to redirect in the previous controller action instead of the redirect(index) You cannot redirect from inside a model

Re: $this-redirect from a Model?

2008-04-30 Thread [EMAIL PROTECTED]
post. I would like to redirect after save! I know it's a bad idea to redirect from Model, but I'm looking for a solution to stop action after a record save, like the return false in before Save. In fact, in my Model::afterSave, I do a move_uploaded_file() and if this move doesn't work, I

Re: $this-redirect from a Model?

2008-04-30 Thread avairet
PROTECTED] wrote: In fact, in my Model::afterSave, I do a move_uploaded_file() and if this move doesn't work, I would like to redirect in the previous controller action instead of the redirect(index) You cannot redirect from inside a model, like Clark said. You must get your model to return

Re: $this-redirect from a Model?

2008-04-30 Thread avairet
to redirect in the previous controller action instead of the redirect(index) You cannot redirect from inside a model, like Clark said. You must get your model to return some value to the controller that you can use to determine if you need to redirect or not. Again, this comes

Re: $this-redirect from a Model?

2008-04-30 Thread [EMAIL PROTECTED]
PROTECTED] wrote:  In fact, in my Model::afterSave, I do a move_uploaded_file() and if  this move doesn't work, I would like to redirect in the previous  controller action instead of the redirect(index) You cannot redirect from inside a model, like Clark said.  You must get your

Re: $this-redirect from a Model?

2008-04-30 Thread avairet
) You cannot redirect from inside a model, like Clark said. You must get your model to return some value to the controller that you can use to determine if you need to redirect or not. Again, this comes with understanding both Cake's conventions and understanding how Cake's

Re: $this-redirect from a Model?

2008-04-30 Thread [EMAIL PROTECTED]
] wrote:  In fact, in my Model::afterSave, I do a move_uploaded_file() and if  this move doesn't work, I would like to redirect in the previous  controller action instead of the redirect(index) You cannot redirect from inside a model, like Clark said.  You must get