Вопрос

like in title - I want to save a content of a text file in database (and couple other things) through rails console - how to do it?

I'm entering rails console by: rails c and then I should do

`MyItem.create! body: content_from_my_text_file, field1: '123', field2: 'abc'

but how force rails console to read from file and write the content to the database? Is there any simple solution? Please help!

Это было полезно?

Решение

You don't need rails to read a file. You could get all the data of a file in a string with IO.read(path).

You should read more about it in:

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top