Forum: Ruby on Rails inserting multiple rows in the table ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A81761f85351593cc242325a8d2f4de4?d=identicon&s=25 swathi mamadgi (Guest)
on 2007-01-26 22:41
Hello,

I have to insert multiple rows into the table.

For each useraction as written below,i should insert userid and
similar(checkbox) into the relations table.But everytime only the first
useraction is entered in one row of table.I want to insert multiple rows
for all the useractions.Let me know if anyone has any clue abt
this.Thank You!

<%= form_tag(:controller => 'content' , :action => "save" ) %>
<% for @user_action in @user_actions %>
userid <%= @user_action.user_id%>
Similar<%= check_box("relation", "similar") %>
<br>
<%end%>
<br>
<%= submit_tag "CreateRelation" %>
<%= end_form_tag %>

Controller code:
def save
  @relation = Relation.create(params[:relation])
  @relation.userid = current_user.id
  @relation.save!
  redirect_to :action => 'index'
end
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2007-01-26 23:39
(Received via mailing list)
Hi Swathi,

swathi mamadgi wrote:
>
> I have to insert multiple rows into the table.

Are you talking about a database table?  Or a DOM table?

Thanks,
Bill
This topic is locked and can not be replied to.