Commit d7e23fa6
Changed files (6)
app
controllers
models
uploaders
views
creations
app/controllers/creations_controller.rb
@@ -27,7 +27,7 @@ class CreationsController < ApplicationController
@creation.category_ids = params[:creation][:category_ids] ||= []
respond_to do |format|
if @creation.save
- format.html { render :action => "crop" }
+ format.html { redirect_to( '/creations/crop/' + @creation.id.to_s ) }
else
flash[:error] = @creation.errors.full_messages
format.html { render :action => "new" }
app/models/creation.rb
@@ -2,7 +2,7 @@ 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, :is_restricted
+ attr_accessible :user_id, :story, :name, :image, :remote_image_url, :category_ids, :is_restricted, :caption
belongs_to :user
has_and_belongs_to_many :categories, :join_table => 'creations_categories', :uniq => true, :autosave => true
has_many :photos, :dependent => :destroy
app/uploaders/image_uploader.rb
@@ -40,7 +40,7 @@ class ImageUploader < CarrierWave::Uploader::Base
gc.font_weight = Magick::BoldWeight
gc.stroke = 'none'
mark = Magick::Image.new(image.columns, image.rows)
- gc.annotate(mark, 0, 0, 25, 25, "CakeSide.com")
+ gc.annotate(mark, 0, 0, 25, 25, model.name)
mark = mark.shade(true, 310, 30)
image.composite!(mark, Magick::SouthEastGravity, Magick::HardLightCompositeOp)
end
app/views/creations/_form.html.erb
@@ -12,6 +12,12 @@
<%= f.file_field :image, :class => "input-file" %>
</div>
</div>
+ <div class="control-group">
+ <%= f.label :caption, :class => "control-label" %>
+ <div class="controls">
+ <%= f.text_field :caption, :class => "input-xlarge" %>
+ </div>
+ </div>
<div class="control-group">
<%= f.label :story, "Description", :class=> "control-label" %>
<div class="controls">
db/migrate/20120821131902_add_caption_to_creation.rb
@@ -0,0 +1,5 @@
+class AddCaptionToCreation < ActiveRecord::Migration
+ def change
+ add_column :creations, :caption, :string
+ 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 => 20120808033601) do
+ActiveRecord::Schema.define(:version => 20120821131902) do
create_table "active_admin_comments", :force => true do |t|
t.integer "resource_id", :null => false
@@ -85,6 +85,7 @@ ActiveRecord::Schema.define(:version => 20120808033601) do
t.integer "user_id"
t.string "image"
t.boolean "is_restricted", :default => false, :null => false
+ t.string "caption"
end
create_table "creations_categories", :id => false, :force => true do |t|