Hi Mike Chai
What I understood is you have relations like
comment has_one picture
picture belongs_to comment
As an example
comment name:string
picture name:string,comment_id:integer
So do as below
in comments_controller new action
@comment = Comment.new
@comment.picture = Picture.new
Now in view/comments/new.html.erb
<% form_for(@comment) do |f| %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<% f.fields_for :picture do |p| %>
<%= p.text_field :name %>
<% end %>
</p>
<p>
<%= f.submit ''Create'' %>
</p>
<% end %>
in model Comment write (modify this according to your needs)
has_one :picture,:dependent => :destroy
accepts_nested_attributes_for :picture,:reject_if => proc { |attributes|
attributes[''name''].blank? }
in create action of comments controller
@comment = Comment.new(params[:comment])
@comment.save
Thats all..Modify the rest of your code like this..This is just an
example
Sijo
--
Posted via http://www.ruby-forum.com/.