【问题标题】:Setting up the get_shorty plugin for bit.ly shortlinks on rails在 rails 上为 bit.ly 短链接设置 get_shorty 插件
【发布时间】:2011-02-27 23:38:59
【问题描述】:

我正在尝试获取 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”

我该如何设置?我是否将 routes.rb 包含到模型中并使用辅助方法?

【问题讨论】:

    标签: ruby-on-rails routes bit.ly


    【解决方案1】:

    插件在 README 中没有提到这个long_url_host,而是按照预期使用 bit.ly api 来尝试。

    您应该在初始化程序中设置您的 api_key 和凭据,并将 has_short_url 放入模型中。

    【讨论】:

    • 在没有参数的情况下首先尝试了它,但无法从 bitly 获取任何短链接。很确定我正确设置了初始化程序。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-08
    • 2019-07-17
    相关资源
    最近更新 更多