Commit f793b7d6

mo khan <mo@mokhan.ca>
2014-08-16 19:03:49
rename is_admin to admin on users table.
1 parent e1e23cd
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: '')
app/views/shared/_account_nav.html.erb
@@ -8,7 +8,7 @@
       <li class="<%= selected == :password ? "active" : "" %>"><%= link_to "Password", my_passwords_path %></li>
       <li class="<%= selected == :picture ? "active" : "" %>"><%= link_to "Picture", edit_my_avatar_path(current_user) %></li>
       <li class="pull-right"><%= link_to t('.logout'), logout_path, method: :delete, class: "btn btn-inverse" %></li>
-      <% if current_user.is_admin? %>
+      <% if current_user.admin? %>
       <li class="pull-right"><%= link_to t('.admin'), admin_root_path %></li>
       <% end %>
     </ul>
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