I am trying to create a ActiveRecord database by using Ruby on Rails
I have created a database Schema:

To create tables destinations, productions, rules I am using rails generate model Name parameter:integer
How to create a table rule_input with foreign key to rule?
Also, how to create a table or a model sources that would join all these tables and I could get source like: source = Source.find(1) and for example render json: {source: source}?