rails 3 project, how to use tinyurl?

735 views Asked by At

Is anyone aware of how to get inyurls in a ruby 192/rails 3 app?

I thought this would be simple... installed the gem 'shorturl' also added it to my Gemfile, did bundle install, and it all looked fine except when I run rails console it immediately throws an error so it's apparently not compatible with ruby 192/rails3.

c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require': c:/Ruby192/lib/ruby/gems/1.9.1/gems/shorturl-0.8.8/lib/short
url.rb:42: syntax error, unexpected ':', expecting keyword_then or ',' or ';' or '\n' (SyntaxError)
                 when :post: http.post(@action, "#{@field...

I considered using Bitly, the gem installed fine, but bitly makes PUBLIC all of the urls you shorten... really not a good idea since we're providing urls to private links.

1

There are 1 answers

1
Adrian Pacala On

The when x: syntax is not compatible with Ruby 1.9 (you have to use when x then). Contact the gem author or fix it yourself by forking the repo. Alternatively you can use Ruby 1.8.7 for this.