Вопрос

i just can not figure out the best way to handle the routes / controller with the following namespace. i´d just like to have the following setup:

.../manage/rooms/  ( <%= @ rooms.number_of_rooms%>, <%= @ rooms.title %> )
.../manage/fuu/     ( <%= @ fuu.id %>...) 
..manage/foo/       ...

i know this is done by routes.rb

namespace :manage do
resources :rooms, :fuu, :foo
end

and under ...controller/manage/rooms_controller.rb and fuu_controller.rb and foo... example:

class Manage::RoomsController < ApplicationController

 index
 @rooms = Rooms.all
 end
 def create
 @room = Room.new(room_params)
  if @room.save
   redirect_to [:manage, @room]
  else
   render 'new'
 end
 ...
end

and a controller under controller/manage_controller.rb

class ManageController < ApplicationController
end

so here is my question i do like to use all of my forms and variables @rooms.title...who are under .../manage/rooms/ .../manage/fuu/ .... under the .../manage/index.html.erb

is the best way to do it via the controller e.g. render partial or changing the controller which the routes point to?

thanks!!!

Это было полезно?

Решение

I would use partials in this situation. If they are all shared in that namespace, it makes sense for the location to be the manage views directory. If they weren't namespaced but still being shared, I'd create a 'shared' directory in views.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top