Commit 0ca05368

mo k <mo@mokhan.ca>
2012-10-28 04:01:36
only show published creations and mark a creation as published after the first photo is uploaded.
1 parent 4d49df8
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.where(:is_restricted => false).page(params[:page]).per(16)
+    @creations = Creation.where(:is_restricted => false, :is_published => true).page(params[:page]).per(16)
   end
 
   # GET /creations/1
app/controllers/photos_controller.rb
@@ -22,6 +22,7 @@ class PhotosController < ApplicationController
 
     @photo = @creation.photos.build(attributes)
     if @photo.save
+      @creation.delay.publish
       respond_to do |format|
         format.html { render :json => [@photo.to_jq_upload].to_json, :content_type => 'text/html', :layout => false }
         format.json { render :json => [@photo.to_jq_upload].to_json }
app/models/creation.rb
@@ -38,5 +38,6 @@ class Creation < ActiveRecord::Base
 
   def publish
     self.update_attribute(:is_published, true)
+    self.save!
   end
 end