Вложенная форма не появляется!

У меня есть вложенная структура модели, которая выглядит следующим образом:

resources :users, :path => '/' do
    resources :accounts do
        resources :characters
    end
end

Я пытаюсь получить страницу accounts # new для отображения отображаются обе формы, но по какой-то причине отображается только форма учетных записей ( скриншот ).

Вот git: https://github.com/imjp/d2shed

account.rb

class Account < ActiveRecord::Base
attr_accessible :account_name, :realm
accepts_nested_attributes_for :characters

belongs_to :user
has_many :characters, :dependent => :destroy 

validates :account_name, :presence => 'true',
                    :length => { :in => 4..20 },
                    :uniqueness => 'true'

validates_presence_of :realm
validates_format_of :account_name, :with => /^[A-Za-z\d_]+$/
end



accounts_controller.rb

def new 
    @user = User.find(params[:user_id])
    @account = Account.new
    @account.characters.build
end



_form.html.erb

<%= form_for([@user, @account]) do |f| %>
<%= f.label :account_name %>
<%= f.text_field :account_name %>
<%= f.radio_button(:realm, "USWest") %> <%= f.label(:realm, "USWest") %> <%= f.radio_button(:realm, "USEast") %> <%= f.label(:realm, "USEast") %> <%= f.radio_button(:realm, "Europe") %> <%= f.label(:realm, "Europe") %> <%= f.radio_button(:realm, "Asia") %> <%= f.label(:realm, "Asia") %>
<%= f.fields_for :character do |character_form| %>
Name: <%= character_form.text_field :name %>
<% end %>
<%= f.submit %>
<% end %>

РЕДАКТИРОВАТЬ: Теперь код работает!

5
задан imjp 29 July 2011 в 06:36
поделиться