Commit 1eeecceb

mo k <mo@mokhan.ca>
2012-07-17 12:48:05
add is_restricted column to creation
1 parent 1c782a1
app/models/creation.rb
@@ -1,8 +1,8 @@
 class Creation < ActiveRecord::Base
   acts_as_commentable
   validates :name,  :presence => true
-  validates :image,  :presence => true
-  attr_accessible :user_id, :story, :name, :image, :remote_image_url, :category_ids
+  validates :image, :presence => true
+  attr_accessible :user_id, :story, :name, :image, :remote_image_url, :category_ids, :is_restricted
   belongs_to :user
   has_and_belongs_to_many :categories, :join_table => 'creations_categories', :uniq => true, :autosave => true
   has_many :photos, :dependent => :destroy
db/migrate/20120717123632_add_is_restricted_to_creation.rb
@@ -0,0 +1,8 @@
+class AddIsRestrictedToCreation < ActiveRecord::Migration
+  def change
+    add_column :creations, :is_restricted, :boolean
+    Creation.joins(:categories).where(:categories => {:slug => 'Naughty Cakes'}).each do |creation|
+      creation.update_attributes! :is_restricted => true
+    end
+  end
+end
db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20120607130928) do
+ActiveRecord::Schema.define(:version => 20120717123632) do
 
   create_table "active_admin_comments", :force => true do |t|
     t.integer  "resource_id",   :null => false
@@ -29,18 +29,18 @@ ActiveRecord::Schema.define(:version => 20120607130928) do
   add_index "active_admin_comments", ["resource_type", "resource_id"], :name => "index_admin_notes_on_resource_type_and_resource_id"
 
   create_table "admin_users", :force => true do |t|
-    t.string   "email",                                 :default => "", :null => false
-    t.string   "encrypted_password",     :limit => 128, :default => "", :null => false
+    t.string   "email",                  :default => "", :null => false
+    t.string   "encrypted_password",     :default => "", :null => false
     t.string   "reset_password_token"
     t.datetime "reset_password_sent_at"
     t.datetime "remember_created_at"
-    t.integer  "sign_in_count",                         :default => 0
+    t.integer  "sign_in_count",          :default => 0
     t.datetime "current_sign_in_at"
     t.datetime "last_sign_in_at"
     t.string   "current_sign_in_ip"
     t.string   "last_sign_in_ip"
-    t.datetime "created_at",                                            :null => false
-    t.datetime "updated_at",                                            :null => false
+    t.datetime "created_at",                             :null => false
+    t.datetime "updated_at",                             :null => false
   end
 
   add_index "admin_users", ["email"], :name => "index_admin_users_on_email", :unique => true
@@ -73,10 +73,11 @@ ActiveRecord::Schema.define(:version => 20120607130928) 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"
   end
 
   create_table "creations_categories", :id => false, :force => true do |t|
@@ -105,18 +106,18 @@ ActiveRecord::Schema.define(:version => 20120607130928) do
   end
 
   create_table "users", :force => true do |t|
-    t.string   "email",                                 :default => "", :null => false
-    t.string   "encrypted_password",     :limit => 128, :default => "", :null => false
+    t.string   "email",                  :default => "", :null => false
+    t.string   "encrypted_password",     :default => "", :null => false
     t.string   "reset_password_token"
     t.datetime "reset_password_sent_at"
     t.datetime "remember_created_at"
-    t.integer  "sign_in_count",                         :default => 0
+    t.integer  "sign_in_count",          :default => 0
     t.datetime "current_sign_in_at"
     t.datetime "last_sign_in_at"
     t.string   "current_sign_in_ip"
     t.string   "last_sign_in_ip"
-    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.string   "name"
     t.string   "website"
     t.string   "twitter"