0
votes

I'm following Ryan Bates' RailsCast #288 "Billing with Stripe" and when I modify my form to include the credit card info I get the following error:

compile error
/Programs/domainster/app/views/domains/_form.html.erb:23: syntax error, unexpected ':',    expecting ')'
...d_tag :card_number, nil, name: nil );@output_buffer.safe_con...

I checked my syntax against the RailsCast and the code is identical. I even updated my GemFile to make sure I have the latest Rails running.

Here's my form:

<div class="field">
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <%= f.label :description %><br />
    <%= f.text_area :description %>
  </div>
  <div class="field">
    <%= label_tag :card_number, "Credit Card Number" %><br />
    <%= text_field_tag :card_number, nil, name: nil %>
  </div>
  <div class="field">
    <%= label_tag :cvv, "Security Code on Card (CVV)" %><br />
    <%= text_field_tag :cvv, nil, name: nil %>
  </div>
  <div class="field">
    <%= label_tag :card_month, "Card Expiration" %><br />
    <%= select_month nil, {add_month_numbers: true}, {name: nil, id: "card_month"} %>
    <%= select_year nil, {start_year: Date.today.year, end_year: Date.today.year+15}, {name: nil, id: "card_year"} %>
  </div>
  <div class="actions">
    <%= f.submit "Generate"%>
  </div>

I followed the RailsCast step-by-step and I have no idea why I'm getting this error. Any ideas?

1
what does ruby -v give you from the console?John Beynon

1 Answers

5
votes

The problem is that Ryan is using a Ruby 1.9.2 syntax for hashes

 <%= select_year nil, {start_year: Date.today.year, end_year: Date.today.year+15}, {name: nil, id: "card_year"} %>

would need to be written as

<%= select_year nil, {:start_year => Date.today.year, :end_year => Date.today.year+15}, {:name => nil, :id => "card_year"} %>

for running on 1.8.7. Check the other lines to see if there are others that need fixing.