I have two classes: User and Delivery.
class Ruser < ActiveRecord::Base
has_many :deliveries, :dependent => :destroy
class Delivery < ActiveRecord::Base
belongs_to :ruser
In the User show action I have put:
<%= render :partial => ''deliveries/form'' %>
So that showing the user I can create a delivery for it.
Delivery form is:
<%= form_for(@delivery) do |f| %>
<% if @delivery.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@delivery.errors.count, "error") %>
prohibited
this delivery from being saved:</h2>
<ul>
<% @delivery.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :delivered_at %>:
<%= l Date.today %><br /><br />
</div>
<div class="field">
<%= f.label :notes%><br />
<%= f.text_area :notes %>
</div>
<%= f.hidden_field :ruser_id, :value => @ruser.id %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
Is it a good code or there is a better mode to create a delivery for one user?
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.