WItam
Probuje zrobic tutorial jak w railscast ponizej
Jestem w momencie w ktorym powinienem widziec cos takiego
Niestety nie widze. Widze jedynie name, a nie widze Questions. Czy moze w bibliotekach jest problem? Dodalem layout jak w tutorialu nifty:layout
<!DOCTYPE html>
<html>
<head>
<title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
<%= yield(:head) %>
</head>
<body>
<div id="container">
<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
<% end %>
<%= content_tag :h1, yield(:title) if show_title? %>
<%= yield %>
</div>
</body>
</html>
Modele
class Question < ActiveRecord::Base
attr_accessible :content, :survey_id
belongs_to :survey
end
class Survey < ActiveRecord::Base
attr_accessible :name
has_many :questions, :dependent => :destroy
accepts_nested_attributes_for :questions
end
W kontrolerze mam tez
def new
@survey = Survey.new
3.times { @survey.questions.build }
end
_form.erb.html
<%= form_for @survey do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<% f.fields_for :questions do |builder| %>
<p>
<%= builder.label :content, "Question" %><br />
<%= builder.text_area :content, :rows => 3 %>
</p>
<% end %>
<p><%= f.submit "Submit" %></p>
<% end %>
Rails 3.2.7