cheat sheets.

$ cheat hwh_nested_attributes
class User < ActiveRecord::Base
  accepts_nested_attributes_for :account_setting
  ...
end

// app/views/users/edit.html.erb
<%= form_for( @user ) do |f| %>
  ...
  <%= f.fields_for :account_setting do |a| %>
    ...

// 
class UsersController < ApplicationController
  def new
    @user = User.new( :account_setting => AccountSetting.new )
  end

  def create
    @user = User.create( params[ :user ] )
  end
end
Version 1, updated 96 days ago.
. o 0 ( edit | history )
( add new | see all )