0
<%= form_for :content, url: contents_path, method: :post do |f| %>

  <%= f.label :inout %> <!-- 수입 지출 목록 -->
  <%= f.text_field :inout %><br>

  <div class="input-group mb-3">
    <div class="input-group-prepend">
      <label class="input-group-text" for="inputGroupSelect01">Options</label>
    </div>
    <select class="custom-select" id="inputGroupSelect01">
    <option selected>Choose...</option>
    <option value="1">결혼식</option>
    <option value="2">장례식</option>
    <option value="3">돌잔치</option>
    </select>
  </div>

  <% if option == 1? %>
    <%= f.hidden_field :category, value=>"결혼식" %>
  <% end %>

  <%= f.label :title %>
  <%= f.text_field :title %>

  <%= f.label :cost %>
  <%= f.text_field :cost %>

  <%= f.label :memo %>
  <%= f.text_area :memo %>

  <%= f.submit %>
<% end %>

I'm getting the following syntax error in my code :

Unexpected ";", expected ";" .... syntax error, unexpected keyword_ensure, expecting_end_of_input

enter image description here

If I select option value one, I store "결혼식" in category and I want to see "결혼식" in the show view

Can you identify what is causing the error?

Francis
  • 1,798
  • 1
  • 26
  • 32
dj-Yang
  • 138
  • 10

1 Answers1

0

Did you copy and paste the code from somewhere else? It's quite possible there might be some zero-width space or other hidden characters in your code that the ruby compiler is not liking.

You can use sublime text on OS/X or Notepad++ to try and see if there are hidden characters in your code.

If you're on OS/X or Linux, you can use Sublime Text and this plug-in to identify those characters

https://pastebin.com/ehWxNfMe

# http://sublimetext.userecho.com/topic/104394-is-it-possible-to-show-all-characters-spaces-tabs-cr-lf-etc/#comment_180170
import sublime_plugin


class ShowZeroWidthSpace(sublime_plugin.EventListener):
    def on_modified(self, view):
        spaces = []
        p = 0
        while 1:
            s = view.find(u'\u200b', p + 1)
            if not s:
                break
            spaces.append(s)
            p = s.a

        if spaces:
            view.add_regions("zero-width", spaces, "string")
        else:
            view.erase_regions("zero-width")

If you're on Windows, you can try using Notepad++ and changing the encoding to Encode in utf-8 BOM

If allo , you can also create a new ruby file and type in the code manually to ensure there's no zero-width or invisble characters that ruby doesn't like.

Rails 4 - syntax error, unexpected tIDENTIFIER, expecting end-of-input

How to remove non-printable/invisible characters in ruby?

Francis
  • 1,798
  • 1
  • 26
  • 32