Skip to content

Namespaces Assets to avoid collisions with existing Asset models. #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/assets/javascripts/activeadmin-wysihtml5/base.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
refreshAssets = ->
$gallery.empty()

$.getJSON '/admin/assets.json', (data) ->
$.getJSON '/admin/wysi_html_five_assets.json', (data) ->
$.each data, (i, asset) ->
$img = $("<img/>")
$img.attr
Expand All @@ -120,7 +120,7 @@
initUploader = ->
uploader = new qq.FileUploader
element: $uploader.get(0)
action: '/admin/assets.json'
action: '/admin/wysi_html_five_assets.json'
onComplete: ->
refreshAssets()
$tab_handles.eq(1).click()
Expand Down Expand Up @@ -205,4 +205,3 @@
)

)(jQuery)

3 changes: 1 addition & 2 deletions app/models/asset.rb → app/models/wysi_html_five_asset.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Asset < ActiveRecord::Base
class WysiHtmlFiveAsset < ActiveRecord::Base
image_accessor :storage

def percentage_thumb_url(size)
Expand Down Expand Up @@ -27,4 +27,3 @@ def as_json(options = {})
}
end
end

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class CreateActiveAdminWysihtml5Assets < ActiveRecord::Migration

def change
create_table :assets do |t|
create_table :wysi_html_five_assets do |t|
t.string :storage_uid
t.string :storage_name
t.timestamps
Expand Down
14 changes: 7 additions & 7 deletions db/migrate/20130124143200_add_magic_attributes_to_assets.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class AddMagicAttributesToAssets < ActiveRecord::Migration
def change
add_column :assets, :storage_width, :integer
add_column :assets, :storage_height, :integer
add_column :assets, :storage_aspect_ratio, :float
add_column :assets, :storage_depth, :integer
add_column :assets, :storage_format, :string
add_column :assets, :storage_mime_type, :string
add_column :assets, :storage_size, :string
add_column :wysi_html_five_assets, :storage_width, :integer
add_column :wysi_html_five_assets, :storage_height, :integer
add_column :wysi_html_five_assets, :storage_aspect_ratio, :float
add_column :wysi_html_five_assets, :storage_depth, :integer
add_column :wysi_html_five_assets, :storage_format, :string
add_column :wysi_html_five_assets, :storage_mime_type, :string
add_column :wysi_html_five_assets, :storage_size, :string
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ActiveAdmin.register Asset do
ActiveAdmin.register WysiHtmlFiveAsset do

index as: :grid do |asset|
link_to(image_tag(asset.storage.thumb("100x100#").url), admin_asset_path(asset))
Expand Down Expand Up @@ -42,7 +42,7 @@ def create
# If an app is using Rack::RawUpload, it can just use
# params['file'] and not worry with original_filename parsing.
if params['file']
@asset = Asset.new
@asset = WysiHtmlFiveAsset.new
@asset.storage = params['file']

if @asset.save!
Expand All @@ -51,7 +51,7 @@ def create
render nothing: true, status: 500 and return
end
elsif params['qqfile']
@asset = Asset.new
@asset = WysiHtmlFiveAsset.new
io = request.env['rack.input']
# throw io

Expand All @@ -73,4 +73,3 @@ def create

end
end