vrfs-927: carrrierwave integration
This commit is contained in:
parent
b731bd84e0
commit
9e4995a55b
|
|
@ -34,6 +34,7 @@ end
|
|||
gem 'will_paginate', '3.0.3'
|
||||
gem 'bootstrap-will_paginate', '0.0.6'
|
||||
gem 'carrierwave', '0.9.0'
|
||||
gem 'carrierwave_direct'
|
||||
gem 'uuidtools', '2.1.2'
|
||||
gem 'bcrypt-ruby', '3.0.1'
|
||||
gem 'jquery-rails', '2.3.0' # pinned because jquery-ui-rails was split from jquery-rails, but activeadmin doesn't support this gem yet
|
||||
|
|
|
|||
|
|
@ -100,6 +100,8 @@ ActiveAdmin.register JamRuby::PromoBuzz, :as => 'Buzz' do
|
|||
def new
|
||||
@promo = JamRuby::PromoBuzz.new
|
||||
@promo.aasm_state = 'active'
|
||||
@uploader = @promo.image
|
||||
# @uploader.success_action_redirect = new_painting_url
|
||||
super
|
||||
end
|
||||
|
||||
|
|
@ -108,6 +110,15 @@ ActiveAdmin.register JamRuby::PromoBuzz, :as => 'Buzz' do
|
|||
super
|
||||
end
|
||||
|
||||
def edit
|
||||
@promo = resource
|
||||
super
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
# encoding: utf-8
|
||||
|
||||
class ImageUploader < CarrierWave::Uploader::Base
|
||||
include CarrierWaveDirect::Uploader
|
||||
|
||||
include CarrierWave::MimeTypes
|
||||
process :set_content_type
|
||||
storage :fog
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
def extension_white_list
|
||||
%w(jpg jpeg gif png)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<%= semantic_form_for([:admin, @promo], :html => {:multipart => true}, :url => @promo.new_record? ? admin_buzzs_path : admin_buzzs_path(@promo)) do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= hidden_field_tag :referring_url, URI::encode(request.referrer) %>
|
||||
<%= f.input(:text_short, :label => "Short Text", :input_html => {:maxlength => 512}) %>
|
||||
<%= f.input(:text_long, :label => "Long Text", :input_html => {:rows => 3, :maxlength => 4096}) %>
|
||||
<%= f.input(:aasm_state, :as => :select, :collection => Promotional::STATES, :label => 'Status') %>
|
||||
<p>File: <%= @promo.image_name %></p>
|
||||
<% # = f.hidden_field :key %>
|
||||
<% # = f.input(:photo, :as => :file, :hint => f.template.image_tag(@promo.image_url(:thumb), :size => '50x50')) if @promo.new_record? %>
|
||||
<% end %>
|
||||
<%= f.actions %>
|
||||
<% end %>
|
||||
<%= direct_upload_form_for @uploader do |f| %>
|
||||
<p><%= f.file_field :image %></p>
|
||||
<p><%= f.submit "Upload Image" %></p>
|
||||
<% end %>
|
||||
|
|
@ -76,7 +76,8 @@ module JamAdmin
|
|||
config.assets.precompile += ['active_admin.css', 'active_admin.js', 'active_admin/print.css']
|
||||
|
||||
# set to false to instead use amazon. You will also need to supply amazon secrets
|
||||
config.store_artifacts_to_disk = true
|
||||
config.store_artifacts_to_disk = false
|
||||
config.storage_type = :fog
|
||||
|
||||
# these only need to be set if store_artifact_to_files = false
|
||||
config.aws_artifact_access_key_id = ENV['AWS_KEY']
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
class JamRuby::PromoBuzz < JamRuby::Promotional
|
||||
mount_uploader :image, ImageUploader
|
||||
end
|
||||
Loading…
Reference in New Issue