I have two models:
class User < ActiveRecord::Base
acts_as_authentic
has_many :orders
end
and
class Order < ActiveRecord::Base
belongs_to :user
accepts_nested_attributes_for :user
end
the idea is that if the user is already logged in, I just want to make a order for that user, but if he is not logged in, then I will ask him to register in the same time as making order. here is the form for orders
<%= form_for(@order) do |f| %>
<div class="field">
<%= f.label :quantity %><br />
<%= f.number_field :quantity %>
</div>
<% if current_user %>
<div class="field">
<%= current_user.email%>
</div>
<%else%>
<%= f.fields_for(:user) do |user_form| %>
<%= render "newuser_fields", :f => user_form %>
<% end %>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
and new users fields are:
<div class="field">
<%= f.label :email %><br />
<%= f.text_field :email %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %>
</div>
The problem is that it won't show fields for user!
Any suggestions?