ruby on rails - RubyOnRails Authorization : I have changed my authorization method and after making some changes to routes.rb I am now getting NO ROUTE errors -
in first few lines made changes. there way can post project can give information possible? not using users controller/file @ all. authorization require me use user scaffold, because using newuser scaffold.
cms::application.routes.draw root :to => "home#merchant" controller :sessions 'login' => :new post 'login' => :create delete 'logout' => :destroy end resources :newusers resources :users resources :maintenances resources :leases resources :sales resources :saleterminals resources :salesreps resources :terminaltypes resources :processings resources :manufacturers resources :promotions "community/index" resources :currents resources :merchants "home/index" "home/about" "home/contact" "home/processing101" "home/terminaloptions" "home/weekend" "home/conditionsofuse" "home/privacypolicy" "home/announcements" "home/support" "home/sitemap" "home/search" post "home/search" end
routes
a piece of advice - can dry routes declaring multiple resources sequentially so:
#config/routes.rb cms::application.routes.draw root to: "home#show", id: "merchant" controller :sessions 'login' => :new post 'login' => :create delete 'logout' => :destroy end resources :newusers, :users, :maintenances, :leases, :sales, :saleterminals, :salesreps, :terminaltypes, :processings, :manufacturers, :promotions, :currents, :merchants resources :community, only: :index resources :home, only: [:index, :show] collection post :search end end end
something note moved entire home
actions send show
action. reason being if want show individual pages, you'll need show
action so:
#app/controllers/home_controller.rb class homecontroller < activerecord::base def show render "home##{params[:id]}" end end
authentication vs authorization
authentication whether user or not
authorization whether user has permission things or not
if you're looking authenticate user, may better suited using gem called devise, handles entire authentication process, signup sessions. there railscast here
--
fix
in reference issue, if want show projects information, why don't have projects
controller actions index
, show
:
#config/routes.rb resources :projects, only: [:index, :show]
if want allow users upload or change projects
, can use "admin" area of sorts, this:
#config/routes.rb namespace :admin resources :projects, except: :index #-> /admin/projects/new end
Comments
Post a Comment