0

そのため、登録を実行するためのセットアップを考案しました。登録後、ユーザーはプロファイル #new にリダイレクトされますが、プロファイルを current_user id に添付できません

実際には、まったく機能しません。これが私のprofiles_controller.rbにあるものです

# POST /profiles

def create @profile = current_user.Profile.new(params[:profile])

respond_to do |format|
  if @profile.save
    format.html { redirect_to(@profile, :notice => 'Profile was successfully created.') }
  else
    format.html { render :action => "new" }
  end
end

終わり

未定義のメソッド `Profile' につながる #

4

2 に答える 2

0

使うべきだと思います

@profile = current_user.build_profile(params[:profile])

ここでレールAPIを確認してください

于 2012-05-19T00:54:32.100 に答える
0

だからUserモデルhas_one :profile

もしそうなら、あなたはおそらく望むでしょう:

@profile = current_user.profile.build(params[:profile])

ここでは大文字と小文字 ('profile' と 'Profile') が重要であることに注意してください。

于 2011-01-15T03:22:40.740 に答える