TopperH
TopperH

Reputation: 2223

Move code out of a long controller

I'm refactoring a rails app that has a very bloated create action (more than 200 lines of code).

I'd like to make it much simpler to maintain and move some code out of it. This code doesn't belong to the model, since the app is just grabbing a file and processing it. It is just a lot of ruby code that processes strings.

I would be just happy to create a class called "Processing" and move it in a separate file (maybe in lib/?), but I'm not sure this is the preferred way.

Should I instead package a gem to include in the project. I have no experience in this field, but it might be a cleaner approach.

Upvotes: 0

Views: 220

Answers (1)

Felix
Felix

Reputation: 4716

Depending on the nature of that string processing code put it into a Module or Class (in both cases this should go somewhere under /lib). I would use a gem really only if you think that other projects might benefit from that code. Gems with less than 200 lines are rather uncommon.

Upvotes: 1

Related Questions