How to DRY up this code

Hello,

I have a piece of controller code that needs to be dried up. The part between the big comment blocks (####) is the only (!) part of the code that needs to change for various methods.

I couldn’t figure it out because if I would wrap this code in a Proc or lambda, the render :nothing => true statement would become void because it doesn’t run in the context of the controller anymore.

i dont really see you repeating yourself. the reusable parts of your
code already seem to be moved into methods. i think you are asking
people to refactor your code.......

Commander Johnson wrote in post #958574:

Hello,

I have a piece of controller code that needs to be dried up. The part
between the big comment blocks (####) is the only (!) part of the code
that
needs to change for various methods.

That method is far too long to be in the controller. Most of this
should be abstracted into models.

Better yet, just rip it all out and install Authlogic or Devise. There
is absolutely no reason to write your own authentication code in Rails
when excellent plugins already exist.

Best,

Thanks for your reply (and sorry for this late message, didn’t check)

Creating authentication from scratch was a nice exercise, but next time indeed I’ll just use an auth mechanism.