Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odd number list for hash

I'm trying to get a rails website up and running from github, and I'm encountering these errors:

WARNING: 'task :t, arg, :needs => [deps]' is deprecated.  Please use 'task :t, [args] => [deps]' instead.
    at /Library/Ruby/Gems/1.8/gems/sunspot_rails-1.2.1/lib/sunspot/rails/tasks.rb:41 rake aborted! /Users/robertgrzesik/Documents/RubyOnRails/IndieOption/app/helpers/advertisements_helper.rb:15: odd number list for Hash
          user_id: current_user.id,
                  ^ /Users/robertgrzesik/Documents/RubyOnRails/IndieOption/app/helpers/advertisements_helper.rb:15: syntax error, unexpected ':', expecting '}'
          user_id: current_user.id,
                  ^ /Users/robertgrzesik/Documents/RubyOnRails/IndieOption/app/helpers/advertisements_helper.rb:16: syntax error, unexpected ':', expecting '='
          page: request.url
               ^ /Users/robertgrzesik/Documents/RubyOnRails/IndieOption/app/helpers/advertisements_helper.rb:17: syntax error, unexpected '}', expecting kEND
        })
         ^ /Users/robertgrzesik/Documents/RubyOnRails/IndieOption/app/helpers/advertisements_helper.rb:20: odd number list for Hash
          page: request.url
               ^ /Users/robertgrzesik/Documents/RubyOnRails/IndieOption/app/helpers/advertisements_helper.rb:20: syntax error, unexpected ':', expecting '}'
          page: request.url
               ^ /Users/robertgrzesik/Documents/RubyOnRails/IndieOption/app/helpers/advertisements_helper.rb:21: syntax error, unexpected '}', expecting kEND
        })
         ^

for this code:

if ad
  if current_user
    ad.impressions.create({
      user_id: current_user.id,
      page: request.url
    })
  else
    ad.impressions.create({
      page: request.url
    })
  end
  link_to external_redirect_advertisement_url(ad) do
    image_tag ad.image.url(format)
  end
else
  nil
end
end

Any ideas?

like image 248
Rob Avatar asked Nov 04 '11 18:11

Rob


2 Answers

You're trying to use 1.9 hash syntax (key: value) with a 1.8 Ruby (:key => value).

like image 143
Dave Newton Avatar answered Oct 09 '22 22:10

Dave Newton


What version of Ruby are you running? The hashes look correct at first glance, but the foo: 'bar' hash syntax is 1.9+ only. If you're using Ruby 1.8.x you'll need up upgrade.

like image 33
Emily Avatar answered Oct 09 '22 22:10

Emily