top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to insert multiple records into database using one form in RoR?

0 votes
477 views

I have 4 tables from the first table, I took all data from the two columns and displayed it in the view. For each data, I have two text fields and the user is supposed to fill those data. Having filled data into the text field, how can I insert all the records into the second table using one form only?

posted Jan 14, 2015 by Deepti Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

i just searched google to figure this out a few days ago

synopsis:

use build

http://archive.railsforum.com/viewtopic.php?id=717

answer Jan 14, 2015 by Sumit Pokharna
Similar Questions
+1 vote

I'm not looking for solution, but steps you would take to figure it out. I don't have experience with APIs and I figured that catching youtube data points and storing them in the database would be a great start?

Here is what I'm trying to accomplish: when I insert youtube video link into a form (create), then: thumb, link, title, date uploaded will get saved into the database as soon as I hit "submit." This will allow me to display these videos using the views.

+1 vote

I have just started with rails. I am making a attendance web app. I want to insert student attendance into attendances table and unable to do it as the form just inserts only last entry of the form. Student table and Attendances table have associations (has_many,belongs_to).

Please let me know how the form should be and controller API should look like.

+2 votes

I have code:

if user.role == "topmanager" can :read, ActiveAdmin::Page, :name => "Dashboard"  can :manage, Realty, agent: {agency_id: user.agency_id}...

And I want to add another condition, can :manage, Realty, agent: nilHow to do it? Defining it two times gets error:

UNDEFINED METHOD `REFLECT_ON_ASSOCIATION\' FOR CLASS:CLASS

How can I define multiple conditions for one ability?

0 votes

I am trying to make a custom form and insert into the database but when I click submit nothing happens. Please help me. I did research and changed my code but still same result. I don't know why.

This is the code:

<?php
/*
Template Name: Student
*/
get_header();
?>    
<?php echo "google";?>    
<?php

    if($_POST['Submit'])
        {
         global $wpdb;
         $name=$_POST['aname'];
         $roll=$_POST['aroll'];
         $dept=$_POST['adept'];
              if($wpdb->insert(    
                  'std', array(
                               'name' => $name,
                               'roll' => $roll,
                               'dept' => $dept
                               )
                               ) == false) wp_die('Database insertion failed');
     else 
          echo "<p>Database insertion successful</p>";  
?>
<?php
}
else //else we didnt submit the form, so display the form
{
?>
<form action="" method="post" id="addcourse">
<label> Student Name:<input type="text" 
name="aname" size="30" /></label>
<label> Roll:<input type="text" 
name="aroll" size="30" /></label>
<label> Department:<input type="text" name="adept" size="30" /></label>
<br />
<input type="Submit" id="addcoursesubmit" value="submit" />
</form>
<?php
}

{
}
?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
...