0

IN the first few lines is where i made the changes. Is there a way I can post the project so i can give the most information possible? also i am not using the users controller/file at all. Does authorization require me to use the USer scaffold, because i am using the Newuser scaffold.

Cms::Application.routes.draw do

  root :to => "home#merchant"

  controller :sessions do
    get '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

  get "community/index"
  resources :currents

  resources :merchants

 get "home/index"
 get "home/about"
 get "home/contact"
 get "home/processing101"
 get "home/terminaloptions"
 get "home/weekend"
 get "home/conditionsofuse"
 get "home/privacypolicy"
 get "home/announcements"
 get "home/support"
 get "home/sitemap"
 get "home/search"
 post "home/search"
end
tompave
  • 11,952
  • 7
  • 37
  • 63
ElMerroPero
  • 59
  • 1
  • 7
  • 1
    First of all I guess you mean authentication, rather then authorization, right? If so, do you use any of the well-known authentication gems like devise? Also, please give more information about the exact error you get and which steps you did to before the error occurred – Peter Sorowka Jun 08 '14 at 23:00

1 Answers1

0

Routes

A piece of advice - you can DRY up your routes by declaring multiple resources sequentially like so:

#config/routes.rb
Cms::Application.routes.draw do

  root to: "home#show", id: "merchant"

  controller :sessions do
    get '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] do
      collection do
          post :search
      end
  end
end

Something to note is I moved your entire home actions to send to the show action. Reason being if you want to show individual pages, you'll just need a show action like so:

#app/controllers/home_controller.rb
Class HomeController < ActiveRecord::Base
   def show
      render "home##{params[:id]}"
   end
end

Authentication vs Authorization

Authentication is whether someone is a user or not

Authorization is whether that user has permission to do certain things or not

If you're looking to authenticate the user, you may be better suited to using a gem called Devise, which handles the entire authentication process, from signup to sessions. There is a Railscast about this here

--

Fix

In reference to your issue, if you want to show projects information, why don't you just have a projects controller with the only actions as index and show:

#config/routes.rb
resources :projects, only: [:index, :show]

If you want to then allow users to upload or change projects, you can use an "admin" area of sorts, like this:

#config/routes.rb
namespace :admin do
   resources :projects, except: :index #-> /admin/projects/new
end
Community
  • 1
  • 1
Richard Peck
  • 76,116
  • 9
  • 93
  • 147