2012-08-17から1日間の記事一覧

参考

Active Record Nested Attributes accepts_nested_attributes_forの簡単なまとめ has_one関連でaccepts_nested_attributes_for / fields_forを使う Railsのユーザ認証deviseを用いた簡単かつ突っ込んだ実装 Writing to a second model when using Devise sta…

気になる

でもこの解決の仕方ってviewの中でモデル(コントローラ?)の仕事をしてるような気がしてちょっと気持ち悪い。幾つか他の方法もありそうなのだけど、そこまできにするのはやめた。

登録画面

ユーザが新規登録する際 # views/devise/registrations/new.html.erb といったフォームを埋め込めば、profileがなければ新しく作った上で入力させることが出来ます。 後はユーザに紐付いたプロフィール表示とかその辺りを引き続きやっていきます。一旦メモ。

has_one, belongs_to, nested_attributes_for, profile_attributes

取り敢えず色々調べまくって至った結論。 # app/models/user.rb has_one :profile accepts_nested_attributes_for :profile attr_accessible :... :profile_attributes # app/models/profile.rb belongs_to :user 一応これでユーザとプロフィールの関係性を…

DeviseとProfile

ログイン出来るようになったのは良いんだけどやっぱりプロフィールページとか無いと困るよね…。という訳で試行錯誤してました、ので記録。