E
E
Evgeny Skuridin2013-12-09 20:06:48
Ruby on Rails
Evgeny Skuridin, 2013-12-09 20:06:48

Rails 4. Importing data from another project

There is a video hosting project. Made on Rails 4 (MySql). And if the video base is from another project that needs to be imported. This database looks like 1 sqlite3 file and a directory with the videos themselves.
What should be done.
1. Read data from sqlite and write it to mysql of the main project
2. Copy the video to the given directory of the main project
4. Take screenshots from the video and save them in a specific directory
5. Recode the imported videos
I can do all this separately, the question is how to do it rails way.
Ideally I want to be able to import/encode/take screenshots using rake tasks.
How and where is it better to write code? Create a plugin or engine? Where would you place this code?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arkady Butermanov, 2013-12-09
@skuridin

I would define the Importer module somewhere in the lib directory and call something like Importer.import(some_params) in the rake task.
Also, inside this module, it is worth defining a separate class for each subtask you described. And call the constructors and methods of these classes from the Importer.import method.
PS You can also try interactors. Read about it here: https://github.com/collectiveidea/interactor

O
OnYourLips, 2013-12-09
@OnYourLips

Google rake task

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question