如何在 ruby​​ on Rails 3 中使用 USPS API 中的 Shipping gem?

发布于 2024-12-01 06:37:10 字数 3014 浏览 2 评论 0原文

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

/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 应用程序集成。

谢谢。

I've found the shipping gem for ruby here http://shipping.rubyforge.org/ searching on google for some information on integrating USPS API on a Ruby on rails application but when I install the gem and add it to my Gemfile as i run the bundle install whenever a try to run my application or a rake taks i get the following error:

/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>'

I have removed now the gem from my Gemfile and my application is up and running but, I don't even know if this gem works for Rails 3 or even if this gem works for USPS API.

Any help on this? I need to integrate USPS Web Tools with my Ruby on Rails 3 Application.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末骤雨初歇 2024-12-08 06:37:10

Shipping gem 很旧,无法与 Rails 3 一起使用(最后一次发布是在 2009 年 10 月

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

支持:

  • UPS
  • USPS
  • FedEx
  • 加拿大邮政
  • 新西兰 邮政

The shipping gem is old and will not work with rails 3 (last release was in October 2009)

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

It supports:

  • UPS
  • USPS
  • FedEx
  • Canada Post
  • New Zealand Post
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文