Rails structure, should I use the service level in this case?

I am new to Ruby and Rails, and I am making my first application. I basically parse HTML and send it as JSON to the client.

I now have two sources for HTML data, but I could have more in the future. Because of this, I thought it would be nice to remove the code responsible for parsing the HTML code from the controller and put it in the service level. I came up with this structure:

  • attachment
    • Controllers
      • main_controller.rb
    • model
      • project.rb
      • task.rb
    • services
      • source1_service.rb
      • source2_service.rb

MainController calls both services to get projects and tasks; each service parses its own HTML code.

This is a good decision? Is there any more RoR way to do this?

+3
source share
2

, , ActiveRecord::Base, ( ). , , , , , rails.

+3

Java-, / RoR. , ( , ). , . , , .

-.

, HTML , , , lib/.

+3

All Articles