Answer the question
In order to leave comments, you need to log in
Ruby and Rails query to table?
Hi friends!
There is a Post type, a post table in the database. For example, there is a title table body table
. I go to post/new and fill everything in, everything is ok.
Now I needed to create an options table that will include non-basic things like in post, for example, the text field autor "Author".
I want to add the autor field to the post / new view code, but I don’t know how to make it write to the options table and link it to the news by id.
That is, I need something like this when creating a post:
поле title - заголовок > записывается в таблицу post в title
поле body - текс > записывается в таблицу post в body
поле autor - Имя Фамилия -> а вот что бы эта писалась в таблицу options в autor
Answer the question
In order to leave comments, you need to log in
I understand that you want to associate the Post model with the Option model as Post has_one :option
read here rusrails.ru/active-record-associations
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question