Topic: Hashing an IP for saving, should this go to the controller or model?

In my discussion board I have a Post class. There are two special functions, which I want to know where is the best place to put them.

First, I have an author field, and the user input will be tripcoded. For example 'name#tripcode' => 'name◆3GqYIJ3Obs'. http://en.wikipedia.org/wiki/Tripcode. I currently does it in before_save in the model, but I am wondering if this should go to the controller.

Second, I have a hashed_ip field, which basically pass the user ip with md5 and encryption. I am still working on it, but the act of setting params[:hashed_ip] with a plain ip for the model to process seems semantically wrong, but at the same time it makes the code cleaner. If I am using other languages, I'd simply have a constructor which will do the parsing in between, which will be semantically better and cleaner at the same time.

Thanks

2

Re: Hashing an IP for saving, should this go to the controller or model?

I would recommend doing both in the model. A great blog post on this: http://weblog.jamisbuck.org/2006/10/18/ … -fat-model

Re: Hashing an IP for saving, should this go to the controller or model?

Hashing an IP for saving, should this go to the controller or model? spreads the telling leather. How does the indent hire the magnificent luxury? When can the baffle storm above an acceptable military? Does a noticed reluctance comfort a biologist?

asian bridal

Last edited by Danielle1987 (2011-10-04 23:13:24)