nicolaslazartekaqui
4/15/2014 - 8:27 PM

resources with namespaces

resources with namespaces

resources :pages do
  resources :images, controller: 'pages/images'
end

resources :images
# /app/controllers/pages/images_controller.rb
class Pages::ImagesController < ApplicationController
  ...
  
  def index
    @page = Page.find(params[:page_id])
    @images = @page.images
  end
  
  ...
end
# /app/controllers/images_controller.rb
class ImagesController < ApplicationController
  ...
  
  def index
    @images = Images.all
  end
  
  ...
end