I want to join two tables together. I haven't created the 2nd table as of yet but the first one already exists.
Basically I have this web scrape returning data like:
[
["formatted_sum_fees", "£5.60"],
["formatted_price", "£46.50"],
["formatted_sum_fees", "£4.50"],
["formatted_price", "£37.50"],
["formatted_sum_fees", "£3.30"],
["formatted_price", "£27.50"]
]
I want to place this in a table. And link all these things that are returned from my webscrape to the event.
The new table will have at a guess this structure:
ID|EventID|Price|Fees
How would I go about saving this information (from above) into the new table against an event id?
Then I guess if I want to use it in the controller I would be able to call something set in the model? The event is being created via a raketask. The webscrape can be put into the same task I started to do this but got confused quite fast.
you have to add relation between these two tabels ie in table_2
model add belongs_to table_1
line
& when you create table_2
add event_id
equal to tabel_1
id.
see links below http://apidock.com/rails/ActiveRecord/Associations/ClassMethods/belongs_to
&
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.