All threads / How do I resolve this syntax error

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I resolve this syntax error

Jim Miller asked in Rails

Hi guys,

I have this error and I don't understand what the error is. I'm using Rails 6

syntax error, unexpected tLABEL
stripe_id: customer.id,
~~~~~~~~~
/vagrant/Rails/stripe-test/app/controllers/subscriptions_controller.rb:34: syntax error, unexpected tLABEL, expecting '='

My code is:
options = (
stripe_id: customer.id,
stripe_subscription_id: subscription.id
)

current_user.update(options)

Thanks,
Jim

Presumably you meant options to be a hash? You used () instead of {}

options = {
  stripe_id: customer.id,
  stripe_subscription_id: subscription.id
}
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,629+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.