Reusing the code

Hi!
I have a controller and I want to use the functionality of another
controller ignoring its rendered response. Is that possible?
What the render_component is for?

Regards,
Mohsin

On 21 Feb 2008, at 11:21, MohsinHijazee wrote:

Hi!
I have a controller and I want to use the functionality of another
controller ignoring its rendered response. Is that possible?
What the render_component is for?

render component is dead. don’t use it.
Sounds like you want a module containing the common functionality that
you can include in both places

Fred

would you be more specific in what are you trying to archieve.
what functionality?

Here is the situation:

I have functionality in two controllers. Controller A deletes the
customers totally and the B simply unlinks them from a group. The
logic of both the operations is quit complex and we cannot afford any
modifications for now neither we can replicate the code because it is
covered by tests and this coverage is vital for the survival of the
project.

I derive the C Controller from A so I get the ability to delete the
customers for free but I want this controller be able to call the
function B_Controller#unlink_customer based on the incoming parameters
from the
C_Controller#destroy. How can I do that?

Here is the situation:

I have functionality in two controllers. Controller A deletes the
customers totally and the B simply unlinks them from a group. The
logic of both the operations is quit complex and we cannot afford any
modifications for now neither we can replicate the code because it is
covered by tests and this coverage is vital for the survival of the
project.

I derive the C Controller from A so I get the ability to delete the
customers for free but I want this controller be able to call the
function unlink_customer based on the incoming parmeters from the
C_Controller#destroy. How can I do that?

On 21 Feb 2008, at 12:17, MohsinHijazee wrote:

I derive the C Controller from A so I get the ability to delete the
customers for free but I want this controller be able to call the
function unlink_customer based on the incoming parmeters from the
C_Controller#destroy. How can I do that?

Sounds like none of this code should be in the controllers at all, and
should be in the Customer model, at which point the problem goes away.

Fred

On 21 Feb 2008, at 14:33, MohsinHijazee wrote:

customers for free but I want this controller be able to call the
function unlink_customer based on the incoming parmeters from the
C_Controller#destroy. How can I do that?

Sounds like none of this code should be in the controllers at all,
and
should be in the Customer model, at which point the problem goes
away.
But even if it is this way then? Any way around?

Sticking the code in a module that you include in both controllers
should do the job, but having that much logic in the controllers is
really bad design. I wouldn’t have thought just moving the code into
the customer model would be very complicated (and if you have good
test coverage then such changes are usually less risky)

Fred

On Feb 21, 6:43 pm, Frederick C. [email protected]
wrote:

covered by tests and this coverage is vital for the survival of the
project.

I derive the C Controller from A so I get the ability to delete the
customers for free but I want this controller be able to call the
function unlink_customer based on the incoming parmeters from the
C_Controller#destroy. How can I do that?

Sounds like none of this code should be in the controllers at all, and
should be in the Customer model, at which point the problem goes away.
But even if it is this way then? Any way around?

On Feb 21, 8:31 pm, Frederick C. [email protected]
wrote:

Here is the situation:
I derive the C Controller from A so I get the ability to delete the
Sticking the code in a module that you include in both controllers
should do the job, but having that much logic in the controllers is
really bad design. I wouldn’t have thought just moving the code into
the customer model would be very complicated (and if you have good
test coverage then such changes are usually less risky)

Fred

But what if I do a stunt of emulating that the call comes from a
remote machine? The same process rails takes while executing an
action?

On 22 Feb 2008, at 12:21, MohsinHijazee wrote:

Sounds like none of this code should be in the controllers at all,

Fred

But what if I do a stunt of emulating that the call comes from a
remote machine? The same process rails takes while executing an
action?

If you’re prepared to do something that horrible i really don’t
understand your reticence to make a simple code change. Plus if you
hit the same mongrel you could deadlock.

Fred.

On Feb 22, 5:28 pm, Frederick C. [email protected]
wrote:

Sounds like none of this code should be in the controllers at all,

Fred

But what if I do a stunt of emulating that the call comes from a
remote machine? The same process rails takes while executing an
action?

If you’re prepared to do something that horrible i really don’t
understand your reticence to make a simple code change. Plus if you
hit the same mongrel you could deadlock.

This is because of the test coverage and I do not understand the
fixtures data yet.