Commit f793b7d6
Changed files (6)
app
spec
app/controllers/admin/admin_controller.rb
@@ -6,7 +6,7 @@ module Admin
private
def restrict_access!
- redirect_to root_path unless current_user.try(:is_admin?)
+ redirect_to root_path unless current_user.try(:admin?)
end
end
end
app/models/user.rb
@@ -41,10 +41,6 @@ class User < ActiveRecord::Base
"#{id}-#{name.gsub(/[^a-z0-9]+/i, '-')}"
end
- def is_admin?
- self.is_admin
- end
-
def send_welcome_email
UserMailer.delay.welcome_email(self)
Subscription.delay.subscribe(email: email, first_name: name, last_name: '')
db/migrate/20140816190202_rename_is_admin_to_admin.rb
@@ -0,0 +1,5 @@
+class RenameIsAdminToAdmin < ActiveRecord::Migration
+ def change
+ rename_column :users, :is_admin, :admin
+ end
+end
db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20140815034538) do
+ActiveRecord::Schema.define(version: 20140816190202) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -206,7 +206,7 @@ ActiveRecord::Schema.define(version: 20140815034538) do
t.string "invitation_token"
t.string "full_address"
t.integer "creations_count", default: 0
- t.boolean "is_admin"
+ t.boolean "admin"
end
add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree
spec/factories.rb
@@ -56,7 +56,7 @@ FactoryGirl.define do
website { Faker::Internet.http_url }
city 'calgary'
factory :admin do
- is_admin true
+ admin true
end
end
end