Reputation: 201
Inherited resources is a powerful gem that I can use it to avoid a lot of repeating things. But i still don't understand why it can get a object through end_of_association_chain even i did not pass anything related to its belongs_to model
Upvotes: 3
Views: 2761
Reputation: 2376
Try to look into Rails routes. AFAIK end_of_association_chain
constructs its value based on routes.
/book/1/pages
-> you get the first book pages inside end_of_association_chain
.
See also: https://github.com/activeadmin/inherited_resources#overwriting-defaults
The end_of_association_chain returns your resource after nesting all associations and scopes (more about this below).
I did not look into end_of_association_chain
sourcecodes, but I guess that 'associations' and 'scopes' here mean exactly the route-constructing keywords like:
resource :production, only: [:update], controller: :production, selected_navigation_category: 'production', path: 'marketing' do
resources :photos, only: %i[index update destroy] do
collection do
get 'set/:photo_set', to: :photo_set, as: :photo_set
I have a PhotosController#photo_set
method which contains end_of_association_chain
. I also was wondering - what is this value - until I dove into routes file.
Upvotes: 0