0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

エラーが出ないエラー

Posted at

本日も宜しくお願いします。

さて今日は「エラーが出ないのにシステムが動かない」案件に遭遇して困っている(現在進行形)というものです。

今回は凄くシンプルで、「フォームを使った送信機能の実装です」

あるテキストを入力し、送信を押したらそのテキストが表示される、というシンプルな物のはずなんですが、、、

書いたコードは以下

index.html.erb

rails.qiita.rb
<h1 class = "display-4"><%= @title %></h1>
<p><%= @msg %></p>

<form method = "post" action = "/hello/index">
  <input type = "text" class = "form-control"
   name  = "input1" value = " <%= @value %>" >
  <input type = "submit" class = "btn btn-primary" >
</form>

hello_controller.rb

rails.qiita.rb
def index
    if request.post? then
      @title = 'Result'
      @msg = 'you typed: ' + params['input1'] + '.'
      @value = params['input1']
    else
      @title = 'Index'
      @msg = 'type text...'
      @value = ''
    end
  end

routes.rb

rails.qiita.rb
get 'hello/index'
  get 'hello' , to: 'hello#index'
  post 'hello', to: 'hello#index'
  post 'hello/index'

[input1]がテキストに入力されて送信(post)を受け取ったら画面がかわるはずなんですが、、、
ターミナル上でもエラーが出ておらず、、、

もし誰かこれを見てわかる方がいたら原因を教えてください。(teterailでも質問投げかけたのですが、解答がもらえず困ってます。)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?