joshfrench / rakismet

Easy Akismet and TypePad AntiSpam integration for Rails
MIT License
355 stars 46 forks source link

which is the best way to update my Table and define raskimet attributes ? #19

Closed localguiding closed 12 years ago

localguiding commented 12 years ago

Hi, I read that you have to store optional request variables if you want to process your comments in a later stage. It means that I have to save user_ip, user_agent and referrer in one of my models.

  1. How and when should I store these values in my model. How do I get them ?
  2. is there a standard way to define my table fields or do I have to create them with a migration ?
  3. How should I store or set other vars like: permalink and author_url ? Should I store these 2 in my model as well ?

Thanks !

joshfrench commented 12 years ago
  1. You can get those from the request object in your controller action: request.remote_ip, request.user_agent, and request.referer. You should capture those and store them in the action where the message is created.
  2. You'll need to create a migration to add those fields to your Message model. You can call the fields whatever you want, and map them with rakismet_attributes (or you can use the default names.)
  3. You should store permalink and author_url just like any other attribute on your Message class.

Hope that helps!

localguiding commented 12 years ago

Yes, you are helping, sorry if my questions are kind dummy.

  1. I guess it is request.referrer and NOT request.referer, right ?
  2. Understood.
  3. is permalink the url where the form is located ? What is the difference between permalink and author_url ?

Thanks again !

joshfrench commented 12 years ago

No worries, happy to help!

  1. I know it's spelled wrong, but it's actually referer -- it was misspelled it in the original HTTP spec in 1996! This can be blank sometimes, so it's not required.
  2. Both permalink and author_url are more useful for a traditional blog model. Permalink usually refers to the permanent URL for a blog post, so in this case maybe you should use the URL for the parent conversation. Author_url usually means whatever URL the author of a comment (not the author of the parent post) would leave along with their comment -- for instance, a link back to the commenter's own blog. If you're not asking your message authors for a URL, it's OK to leave this field out -- it's not required.
localguiding commented 12 years ago

Hi Josh, thanks for your answers ! I really appreciate your help. Just one more regarding the referrer/referer issue. I understand that from rails perspective, referrer is actually request.referer, that's ok. So my question is, how should I name my table field, referer or referrer ?

Thanks for your support !

joshfrench commented 12 years ago

I'd probably call it referrer so it matches the Rakismet default, but if you wanted to call it referer or something else you can always map it with rakismet_attrs.

Do you think it would be clearer if I changed the Rakismet attribute to referer so that it matched the HTTP spec?

localguiding commented 12 years ago

OK, I will follow your recommendation and call it referrer.

Regarding your question, I'm not sure what's the best option, but I'd say to not change it and leave it like it is because this way the map in not needed. Thanks, Alvaro.