On 2 December 2013 06:16, lekha p. <lists@ruby-forum.com> wrote:
> Hi all,
> what you used to do when your controller function gets lengthy
> sometimes ?
> a way i found is just split the function. What is the real and Rails way
> to keep my code cleaner and maintainable.
Probably some of the logic should be removed from the controller and
put into methods in the model(s). So for example look at the code and
anywhere you have a few lines that are to do with extracting data from
the model and manipulating it in some way then consider writing a
model method that implements that function.
You can also extract bits of code into private methods of the
controller, but concentrate first on moving stuff into the models.
Finally, if there is a lot of code interpreting data encoded in the
url then maybe the routes could be improved.
Post one of the methods that you want to re-factor if you need some pointers.
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv2TxY6L%2BZzZUJ_dZ2vAWF-eyeAMcNYLLDMETa44C953A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
1 comment:
Well explained article :)
Thanks
Major Karthik
Post a Comment