class User < ActiveRecord::Base acts_as_authentic has_many :orders end
class Order < ActiveRecord::Base belongs_to :user accepts_nested_attributes_for :user end
<%= 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 %>
<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>
@order.build_user
def new @order = Order.new @order.build_user end
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)