Rails RESTful controllers versus specific controllers

This design issue needs a little context, so please bear with me.

I currently have three models that go something like this:

class MyItem < ActiveRecordBase
    has_many :my_list_items
    ...

class MyList < ActiveRecordBase
    has_many :my_list_items
    has_many :my_items, :through => :my_list_items
    ...

 class MyListItem < ActiveRecordBase
     belongs_to :my_item
     belongs_to :my_list
     has_many :my_list_item_properties

 class MyListItemProperty < ActiveRecordBase
     belongs_to :my_list_item

As you can see, a model is MyListItemmore than a simple join table; it also has other properties.

. MyItems , MyList , CRUD. MyList, MyListItems MyItem . MyItem ( MyListItem) MyItem MyListItem. RJS.

:

  • , , MyItem MyItemController, MyListController, . DRY, / partials/RJS .

  • AJAX MyList submit to MyItemController, , RJS MyList, . , : controller = > my_list link_to_remote MyList . , -, RESTful MyItem , .

?

+3
2

, , №1. , / . /, № 2.

, : " - ". № 2.

, , , before_filter , №1, , .

+3

, lib ( ), DRY , MyItems (, , DRYed MyItem ). . AJAX, , RESTful.

+2

Source: https://habr.com/ru/post/1766974/


All Articles