選択リストの作成時にcontrollers.rbに構文エラーが出る。
Controllers.rbの全文
class TikkaController < ApplicationController
def index if request.post? then @title = "Result" if params["s1"] then @msg = "you selected: " + "params["s1"] else @msg = "not selected..." end else @title = "index" @msg = "select List..." end end
end
index.html.erbの全文
<h1><%= @title %></h1> <p><%= @msg %></p> <%= form_tag(controller: "tikka",action: "index") do %> <%= serect_tag("s1", options_for_select(["Windows", "macOS", "Linux"])) %> <%= submit_tag("Click") %> <% end %>エラー全文
Started GET "/tikka" for 127.0.0.1 at 2017-11-01 22:43:40 +0900
C:/Users/Admin/Ruby22-x64/RailsApp/app/controllers/tikka_controller.rb:12: warning: string literal in condition
SyntaxError (C:/Users/Admin/Ruby22-x64/RailsApp/app/controllers/tikka_controller.rb:7: syntax error, unexpected tIDENTIFIER, expecting keyword_end
@msg = "you selected: " + "params["s1"]
^
C:/Users/Admin/Ruby22-x64/RailsApp/app/controllers/tikka_controller.rb:9: syntax error, unexpected keyword_not, expecting keyword_end
@msg = "not selected..."
^
C:/Users/Admin/Ruby22-x64/RailsApp/app/controllers/tikka_controller.rb:12: syntax error, unexpected tIDENTIFIER, expecting keyword_end
@title = "index"
^
C:/Users/Admin/Ruby22-x64/RailsApp/app/controllers/tikka_controller.rb:13: syntax error, unexpected tIDENTIFIER, expecting keyword_end
@msg = "select List..."
^
C:/Users/Admin/Ruby22-x64/RailsApp/app/controllers/tikka_controller.rb:13: unterminated string meets end of file
C:/Users/Admin/Ruby22-x64/RailsApp/app/controllers/tikka_controller.rb:13: syntax error, unexpected end-of-input, expecting keyword_end):
app/controllers/tikka_controller.rb:7: syntax error, unexpected tIDENTIFIER, expecting keyword_end
app/controllers/tikka_controller.rb:9: syntax error, unexpected keyword_not, expecting keyword_end
app/controllers/tikka_controller.rb:12: syntax error, unexpected tIDENTIFIER, expecting keyword_end
app/controllers/tikka_controller.rb:13: syntax error, unexpected tIDENTIFIER, expecting keyword_end
app/controllers/tikka_controller.rb:13: unterminated string meets end of file
app/controllers/tikka_controller.rb:13: syntax error, unexpected end-of-input, expecting keyword_end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。