Skip to content

Commit

Permalink
working wih a and a
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanbabubb committed Jul 16, 2017
1 parent 469844c commit d656f33
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/home.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/home.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Home controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
10 changes: 10 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class HomeController < ApplicationController

def index

end

def show

end
end
2 changes: 2 additions & 0 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module HomeHelper
end
2 changes: 2 additions & 0 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Home#index</h1>
<p>Find me in app/views/home/index.html.erb</p>
11 changes: 7 additions & 4 deletions config/initializers/rails_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

### Popular gems integration

config.authorize_with do
redirect_to main_app.root_path unless warden.user.admin == true
end
## == Devise ==
# config.authenticate_with do
# warden.authenticate! scope: :user
# end
# config.current_user_method(&:current_user)
config.authenticate_with do
warden.authenticate! scope: :user
end
config.current_user_method(&:current_user)

## == Cancan ==
# config.authorize_with :cancan
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Rails.application.routes.draw do
root 'home#index'

devise_for :users
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170715175243_add_devise_to_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class AddDeviseToUsers < ActiveRecord::Migration[5.1]
def self.up
change_table :users do |t|
## Database authenticatable
t.boolean :admin
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""

Expand Down
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "admin"
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
Expand Down
9 changes: 9 additions & 0 deletions test/controllers/home_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'test_helper'

class HomeControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get home_index_url
assert_response :success
end

end

0 comments on commit d656f33

Please sign in to comment.