Commit ab3ab3dc

mo k <mo@mokhan.ca>
2012-07-17 13:18:23
update migration to set the default is_restricted to false
1 parent 7b33715
app/controllers/creations_controller.rb
@@ -2,7 +2,7 @@ class CreationsController < ApplicationController
   before_filter :authenticate_user!, :except => [:show, :index]
   # GET /creations
   def index
-    @creations = Creation.page(params[:page]).per(16)
+    @creations = Creation.where(:is_restricted => false).page(params[:page]).per(16)
   end
 
   # GET /creations/1
db/migrate/20120717123632_add_is_restricted_to_creation.rb
@@ -1,6 +1,6 @@
 class AddIsRestrictedToCreation < ActiveRecord::Migration
   def change
-    add_column :creations, :is_restricted, :boolean
+    add_column :creations, :is_restricted, :boolean, :default => false, :null => false
     Creation.joins(:categories).where(:categories => {:slug => 'Naughty Cakes'}).each do |creation|
       creation.update_attributes! :is_restricted => true
     end
db/schema.rb
@@ -73,11 +73,11 @@ ActiveRecord::Schema.define(:version => 20120717123632) do
   create_table "creations", :force => true do |t|
     t.string   "name"
     t.text     "story"
-    t.datetime "created_at",    :null => false
-    t.datetime "updated_at",    :null => false
+    t.datetime "created_at",                       :null => false
+    t.datetime "updated_at",                       :null => false
     t.integer  "user_id"
     t.string   "image"
-    t.boolean  "is_restricted"
+    t.boolean  "is_restricted", :default => false, :null => false
   end
 
   create_table "creations_categories", :id => false, :force => true do |t|