Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
localguiding opened this issue Jun 6, 2012 · 6 comments

Comments

@localguiding
Copy link

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
Copy link
Owner

  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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants