Inserting multiple rows in the table?


#1

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”) %>


<%end%>


<%= 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


#2

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