【问题标题】:How to use the shipping gem in ruby on rails 3 for USPS API?如何在 ruby​​ on rails 3 中为 USPS API 使用运输宝石?
【发布时间】:2011-08-23 15:10:12
【问题描述】:

我在这里找到了用于 ruby​​ 的 shipping gem http://shipping.rubyforge.org/ 在 google 上搜索有关在 Ruby on rails 应用程序上集成 USPS API 的一些信息,但是当我安装 gem 并将其添加到我的 Gemfile当我运行 bundle install 时,每当尝试运行我的应用程序或 rake taks 时,我都会收到以下错误:

/Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require': /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/shipping-1.6.0/lib/shipping/ups.rb:109: syntax error, unexpected ':', expecting keyword_then or ';' or '\n' (SyntaxError)
/Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/shipping-1.6.0/lib/shipping/ups.rb:437: syntax error, unexpected keyword_end, expecting $end
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `block in require'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/shipping-1.6.0/lib/shipping.rb:47:in `<top (required)>'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `each'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `each'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `require'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler.rb:120:in `require'
    from /Users/myusername/railsapps/dbh4/config/application.rb:7:in `<top (required)>'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/commands.rb:15:in `require'
    from /Users/myusername/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/commands.rb:15:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我现在已经从我的Gemfile 中删除了 gem,我的应用程序已经启动并正在运行,但是,我什至不知道这个 gem 是否适用于 Rails 3,或者即使这个 gem 是否适用于 USPS API。

对此有任何帮助吗?我需要将 USPS Web 工具与我的 Ruby on Rails 3 应用程序集成。

谢谢。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 gem usps


    【解决方案1】:

    运输 gem 很旧,不能与 rails 3 一起使用(最后一个版本是在 October 2009

    试试https://github.com/Shopify/active_shipping

    它支持:

    • UPS
    • 美国邮政总局
    • 联邦快递
    • 加拿大邮政
    • 新西兰邮政

    【讨论】:

    • 我应该把它放在vendors/plugin 目录上还是用rails plugin install git://github.com/Shopify/active_shipping.git 作为插件安装?
    • 您可以使用 gem install active_shipping 安装或将 gem 'active_shipping' 添加到您的 Gemfile。
    猜你喜欢
    • 2019-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-03
    • 2013-07-15
    • 1970-01-01
    相关资源
    最近更新 更多