前提・実現したいこと
Ruby on railsでwebページを作成中です。
form_forで入力した値をparamsで受け取りたいのですが、うまくいきません。
ページ自体は、ブラウザでは問題なく作動しています。
データベースを確認したところ、入力データの保存自体はされているのですが値をすべてnilとして受け取ってしまっているようで、これをフォームに入力された値で受け取れるようにしたいです。
該当のソースコード
new.html.erb
ruby
1<div class="row"> 2 <div class="theater input-form"> 3 <%= form_for("/theater/new") do |f| %> 4 <%= f.label :user %> 5 <%= f.text_field :user %> 6 7 <%= f.label :theater %> 8 <%= f.text_field :theater %> 9 10 <%= f.label :address %> 11 <%= f.text_field :address %> 12 13 <%= f.label :webpage %> 14 <%= f.text_field :webpage %> 15 16 <%= f.label :fee %> 17 <%= f.text_field :fee %> 18 19 <%= f.label :others %> 20 <%= f.text_field :others %> 21 22 <%= f.submit "登録", class: "btn btn-primary" %> 23 <% end %> 24 </div> 25</div>
theater.controller.rb
ruby
1def create 2 @theater = Theater.new(user: params[:user],theater: params[:theater],address: params[:address], 3 webpage: params[:webpage], fee: params[:fee], others: params[:others]) 4 if @theater.save 5 redirect_to("/") 6 else 7 render 'theater/new' 8 end 9end
補足情報(FW/ツールのバージョンなど)
ruby 2.5.0, rails 5.1.6, cloud9
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。