Jump to content

The ultimate community for Ruby on Rails developers.


Photo

joining table how to model, controller and view


  • Please log in to reply
1 reply to this topic

#1 svajone

svajone

    Passenger

  • Members
  • 3 posts

Posted 11 July 2014 - 04:32 PM

hello.

 

i come a SQL background and i have always been used to having joined tables. example, when a new customer is inputted and they wish to input a product right away but that product is a new entry as well. how would i set up the model, controller and view so that when a form like this:

 

customer name:

phone:

address:

 

new product input:

product name:

product description:

 

when clicking submit, the records for customer name will go to customer table, product to product table and will automatically be paired in the customer_product joining table.

 

thanks for any help!



#2 Jamie

Jamie

    Controller

  • Moderators
  • 140 posts
  • LocationNewcastle, UK

Posted 22 July 2014 - 05:22 PM

hello.

 

i come a SQL background and i have always been used to having joined tables. example, when a new customer is inputted and they wish to input a product right away but that product is a new entry as well. how would i set up the model, controller and view so that when a form like this:

 

customer name:

phone:

address:

 

new product input:

product name:

product description:

 

when clicking submit, the records for customer name will go to customer table, product to product table and will automatically be paired in the customer_product joining table.

 

thanks for any help!

 

Hello

 

You'll want to have a look at nested forms. There are a few tutorials you'll find on Google and if you get stuck. Provide the code you've attempted and we'll do our best to point you in the right direction but that should be enough to get you started.

 

 

:)


  • svajone likes this

Rails developer based in Newcastle, UK.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users