为 Rails 上的 bit.ly 短链接设置 get_shorty 插件
我正在尝试获取 bit.ly 短链接来链接到我的模型的显示页面之一,以获取我想要合并到我的应用程序中的 Twitter 功能。
似乎 https://github.com/playgood/get_shorty 是我能找到的最好的东西在那里,但我在设置时遇到了麻烦。
我认为这就是我的问题所在,但我被难住了:
class Foo < ActiveRecord::Base
include GetShorty
has_short_url :long_url_host => "localhost:3000" :long_url_method => #What should I put here?
插件文档“这可能是一个资源丰富的路由帮助器方法,例如 page_url”
我将如何设置它?我是否将 paths.rb 包含到模型中并使用辅助方法?
I'm trying to get bit.ly shortlinks to link to one of my model's show pages for Twitter functionality that I want to incorporate into my app.
It seems like the https://github.com/playgood/get_shorty is the best thing I could find out there, but I'm having trouble setting it up.
I think this is where my problem is, but I"m stumped:
class Foo < ActiveRecord::Base
include GetShorty
has_short_url :long_url_host => "localhost:3000" :long_url_method => #What should I put here?
The plugin documentation "this would probably be a resourceful route helper method for example page_url"
How would I set that up? Do I include routes.rb into the model and use the helper method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该插件在自述文件中没有提到这个
long_url_host
,但请按照预期使用 bit.ly api 进行尝试。您应该在初始化程序中设置 api_key 和凭据,并将
has_short_url
放入模型中。The plugin didn't mention this
long_url_host
in the README, but try it with the bit.ly api as intended instead.you should just set up your api_key and credentials in an intitializer and put the
has_short_url
in the model.