0

I am still new to Ruby. I have a model of database based on multilingual website. So, the schema of database is

article:
 id

article_lng:
 id
 lng

article_data:
 title
 body 
 ...

Where the ID is in article, 2 or more records for one ID with setting language is in article_lng. And article_data contains data with languge referenced by foreign key. article_lng is something like versions of article. It is common idea so I hope it is clear.

Now I have form in Padrino and I would like to write the form as I was used to with simple one table model, like this in post route in controller

@article = Article.new(params[:article])

And then call save method on the instance of object.

In this new situation I need to create article with 2 languages at one post. So there is creating ID in top table (articles), also 2 lines in articles_lng with this ID (foreign key) and then the data. I hope the structure is clear.

The tables are associated in models of course.

I don't know how to write or structure data during post. Please any suggestions for proper way to do this?

Thanks

Levi
  • 77
  • 7

1 Answers1

0

This is done by nested attributes. I am now blocked in another problem. But, form can be posted via form from top of the associations and style

f.fields_for, :association_name
   f.text_area
   f.fields_for
    ...subform...
Levi
  • 77
  • 7