简体   繁体   中英

How to use the shipping gem in ruby on rails 3 for USPS API?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM