BasicInfoというモデルとコントローラーを生成し、インスタンス変数として@basicinfoというものを以下の通りコントローラーで定義しました。
/app/controllers
、、、、、、、、、、、、、、、、、、、、、、、、、
class BasicInfosController < ApplicationController
def show
@basicinfo = BasicInfo.new
@basicinfo = BasicInfo(params[:id])
binding.pry
end
def new
end
end
、、、、、、、、、、、、、、、、、、、、、、、、、
その上で、ビューで以下の通りしていしたところ、@basicinfoがnilになっているとエラーが帰ってくる状況です。
app/views/basic_infos
、、、、、、、、、、、、、、、、、、、、、、、、、
<% provide(:title, "基本情報登録") %>
<h1>基本情報登録</h1> <div class="row"> <div class="col-md-6 col-md-offset-3"> <%= form_for(@basicinfo, url: basicinfo_path) do |basicinfo_form| %> <%= render 'shared/error_messages' %> <%= basicinfo_form.label :name %> <%= basicinfo_form.text_field :name, class: 'form-control' %> <%= basicinfo_form.label :email %> <%= basicinfo_form.text_field :email, class: 'form-control' %> <%= user_form.submit "Create my account", class: "btn btn-primary" %> <% end %> </div> </div> 、、、、、、、、、、、、、、、、、、、、、、、、、、nilを解消する方法を教えてください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/16 02:59