Rails.application.routes.draw do

  get 'pages/about'

  get 'pages/contact'

  get 'pages/blog'

  mount RailsAdmin::Engine => '/admin', as: 'rails_admin'

  namespace :api do
    resources :posts
  end

  resources :posts do
    member do
      get "vote"
      get "preview"
      post "apply_to"
    end
  end

  devise_for :users, controllers: {
    registrations: "users/registrations",
    sessions: "users/sessions",
    passwords: "users/passwords"
  }, skip: [:sessions, :registrations]


  devise_scope :user do
    get    "login"   => "users/sessions#new",         as: :new_user_session
    post   "login"   => "users/sessions#create",      as: :user_session
    delete "signout" => "users/sessions#destroy",     as: :destroy_user_session

    get    "signup"  => "users/registrations#new",    as: :new_user_registration
    post   "signup"  => "users/registrations#create", as: :user_registration
    delete "signup"  => "users/registrations#destroy", as: :destroy_user_registration
    put    "signup"  => "users/registrations#update", as: :update_user_registration
    get    "account" => "users/registrations#edit",   as: :edit_user_registration
  end

  root 'posts#index'
end
