How can I access cookies from a model in Rails 3

时光毁灭记忆、已成空白 提交于 2019-12-23 18:56:39

问题


I am using the Koala gem to interact with the Facebook API. In order to connect to the API, I need to pass my cookies to Koala. I want to do this in a model because I want to add additional data to the user from Facebook data during a before_create callback in the model. For instance, if a user has an active FB session, store their Facebook UID when creating their user row. How do I get at cookies from within a model?


回答1:


Models should not be aware they're operating in a web environment.

What you might want to consider instead is just storing the FB UID on the model the same way as any other property, by setting it on the model during creation.



来源:https://stackoverflow.com/questions/7884630/how-can-i-access-cookies-from-a-model-in-rails-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!