In my application I have to tables

1) Student
2) Alma Mater Department

Student table belongs_to :alma_mater_department and Alma Mater
Department has_many :students

Firstly, I want to predefined some data in seeds.rb for Alma Mater
table which I want to look like this

+ Type | Name +
+ B.Tech | Mechanical +
+ | Production +
+ | Electronics +
+ M.Tech | Mechanical +
+ | Production +
+ | Electronics +

What is the best approach of doing this kind of seeding (as it has
many repeating values)

Secondly, once done with above step, I want that under student's
new.html.erb there will be two <collection_select> fields

1) Where user can choose from Type
2) Where user can choose from Name

Say, user choose value == B.Tech Production (which according to table
is id=2). How to send that id thing in Student table and display them.

P.S: My problem is bit topsy turvy kinda thing. Please bear with me as
I am leaning these concepts.


Deepak Kumar Sharma
Guru Nanak Dev Engineering College


You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
postedMay 10, '16 at 8:24p
activeMay 10, '16 at 8:24p

1 user in discussion

Deepak Sharma: 1 post



site design / logo © 2021 Grokbase