Develop resources within namespace

Hi,

I want to develop my resources that deal with CRUD operations on my
models in a namespace of /admin. How is the best approach to do this?
What needs to be changed in order to do this? As in my last attempt of
moving things to a namespace my software broke.

TIA,

Dean

On 26 July 2012 14:45, Dean C. [email protected] wrote:

Hi,

I want to develop my resources that deal with CRUD operations on my models in a
namespace of /admin. How is the best approach to do this? What needs to be changed
in order to do this? As in my last attempt of moving things to a namespace my
software broke.

First make sure you are using a source control system such as git so
that you can do the work on a branch and can easily go back if there
are problems. Secondly make sure you have complete automated test
coverage and modify the tests before modifying the code so that you be
sure it is all working correctly.

Colin

Hi,

You need to change several things here.

For example you need to move user to admin

  1. in routes.rb, add this
    namespace :admin do
  • resources :users*
    end
    routes to this user resource will be prefixed by ‘/admin’ like
    ‘/admin/users/index’
  1. create users_controller.rb under admin folder in /app/controllers
    in users_controller.rb, name the class using admin namespace, like
    class Admin::UsersController < ApplicationController
    end

  2. create an admin folder under views, and put all your users’ view
    here.
    done!

Note you do not need to change anything to model. You can refer
namespace
route doc
herehttp://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing

zvaya