lolita-file-upload 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -5
- data/.rspec +2 -2
- data/Gemfile +21 -21
- data/LICENSE.txt +20 -20
- data/README.rdoc +27 -27
- data/Rakefile +39 -39
- data/VERSION +1 -1
- data/app/controllers/lolita/uploads_controller.rb +58 -0
- data/app/models/lolita/upload/file.rb +43 -43
- data/app/uploaders/file_uploader.rb +20 -20
- data/app/views/components/lolita/configuration/tab/files/_cells.html.erb +10 -4
- data/app/views/components/lolita/configuration/tab/files/_destroy.js.erb +2 -2
- data/app/views/components/lolita/configuration/tab/files/_display.html.erb +10 -11
- data/app/views/components/lolita/configuration/tab/files/_edit.js.erb +1 -1
- data/app/views/components/lolita/configuration/tab/files/_file.html.erb +5 -0
- data/app/views/components/lolita/configuration/tab/files/_fixed_gallery.html.haml +33 -0
- data/app/views/components/lolita/configuration/tab/files/_form.html.erb +7 -3
- data/app/views/components/lolita/configuration/tab/files/_list.html.erb +13 -13
- data/app/views/components/lolita/configuration/tab/files/_list_form.html.erb +5 -5
- data/app/views/components/lolita/configuration/tab/files/_row.html.erb +5 -2
- data/app/views/components/lolita/configuration/tab/files/_update.js.erb +1 -1
- data/app/views/components/lolita/configuration/tab/files/_upload_script.html.erb +79 -77
- data/config/locales/en.yml +18 -18
- data/features/configuration_for_tab.feature +25 -25
- data/features/connect_with_lolita.feature +14 -14
- data/features/extend_resources_with_new_routes.feature +16 -16
- data/features/step_definitions/lolita_steps.rb +112 -112
- data/features/support/env.rb +15 -15
- data/features/support_byte_converter.feature +31 -31
- data/features/upload_file.feature +15 -15
- data/lib/generators/lolita_file_upload/assets_generator.rb +12 -12
- data/lib/generators/lolita_file_upload/install_generator.rb +19 -19
- data/lib/generators/lolita_file_upload/templates/migration.rb +24 -24
- data/lib/lolita-file-upload.rb +35 -36
- data/lib/lolita-file-upload/configuration/tab/files.rb +108 -57
- data/lib/lolita-file-upload/module.rb +10 -6
- data/lib/lolita-file-upload/rails.rb +7 -7
- data/lib/lolita-file-upload/rails/file_upload_routes.rb +14 -19
- data/lib/support/bytes.rb +58 -58
- data/lolita-file-upload.gemspec +9 -13
- data/public/javascripts/lolita/upload/I18n/lv.js +21 -21
- data/public/javascripts/lolita/upload/I18n/ru.js +21 -21
- data/public/javascripts/lolita/upload/plupload.full.js +1 -1
- data/public/stylesheets/lolita/upload/jquery.ui.plupload.css +139 -139
- data/public/stylesheets/lolita/upload/plupload.queue.css +177 -177
- data/spec/configuration/tab/files_spec.rb +36 -36
- data/spec/lolita/support/bytes_spec.rb +35 -35
- data/spec/models/file_spec.rb +33 -33
- data/spec/spec_helper.rb +32 -29
- data/spec/support/post.rb +2 -2
- data/spec/uploaders/file_uploader_spec.rb +11 -11
- data/test_orm/active_record.rb +11 -11
- data/test_orm/active_record/news.rb +11 -11
- data/test_orm/active_record/post.rb +12 -12
- data/test_orm/active_record/tag.rb +2 -2
- data/test_orm/config/active_record.yml +1 -1
- data/test_orm/coverage.rb +18 -18
- data/test_orm/db/migrate/01_create_posts.rb +14 -14
- data/test_orm/db/migrate/02_create_files.rb +19 -19
- data/test_orm/db/migrate/03_create_news.rb +16 -16
- data/test_orm/db/migrate/04_create_tags.rb +14 -14
- data/test_orm/files/large_file.txt +201 -201
- data/test_orm/files/normal_file.txt +1 -1
- data/test_orm/rails/config/application.rb +7 -7
- data/test_orm/rails/config/enviroment.rb +4 -4
- data/test_orm/rails/config/routes.rb +2 -2
- data/test_orm/rails/log/development.log +7 -7
- data/test_orm/support.rb +26 -26
- data/test_orm/uploaders/list_image_uploader.rb +5 -5
- data/test_orm/uploaders/main_image_uploader.rb +5 -5
- metadata +19 -23
- data/app/controllers/lolita/upload/files_controller.rb +0 -51
- data/app/controllers/lolita/upload/images_controller.rb +0 -52
- data/lib/lolita-file-upload/configuration/tab/images.rb +0 -20
- data/spec/configuration/tab/images_spec.rb +0 -16
- data/upload/lolita/upload/file/201105/1/large_file.txt +0 -201
- data/upload/lolita/upload/file/201106/1/large_file.txt +0 -201
- data/upload/misc/large_file.txt +0 -201
data/features/support/env.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require File.expand_path('test_orm/coverage')
|
2
|
-
require File.expand_path("lib/lolita-file-upload")
|
3
|
-
require "carrierwave"
|
4
|
-
|
5
|
-
require "ruby-debug"
|
6
|
-
current_orm=:active_record
|
7
|
-
require 'carrierwave/orm/'+current_orm.to_s.gsub("_","")
|
8
|
-
|
9
|
-
require File.expand_path("test_orm/#{current_orm}")
|
10
|
-
|
11
|
-
require File.expand_path("test_orm/support")
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
require File.expand_path('test_orm/coverage')
|
2
|
+
require File.expand_path("lib/lolita-file-upload")
|
3
|
+
require "carrierwave"
|
4
|
+
|
5
|
+
require "ruby-debug"
|
6
|
+
current_orm=:active_record
|
7
|
+
require 'carrierwave/orm/'+current_orm.to_s.gsub("_","")
|
8
|
+
|
9
|
+
require File.expand_path("test_orm/#{current_orm}")
|
10
|
+
|
11
|
+
require File.expand_path("test_orm/support")
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
@@ -1,31 +1,31 @@
|
|
1
|
-
Feature: convert bytes to biggest possible unit
|
2
|
-
|
3
|
-
In order to show file upload errors in human understendable way
|
4
|
-
There should be converter that converts bytes to kilobytes, megabytes, gigabytes.
|
5
|
-
Lolita::Suport::Bytes do that think, it is create by passing bytes, and return unit and values with
|
6
|
-
converted values
|
7
|
-
|
8
|
-
Scenario Outline: convert bytes
|
9
|
-
Given byte converter
|
10
|
-
When I humanize "<size>"
|
11
|
-
Then I should get "<unit>" and "<limit>"
|
12
|
-
|
13
|
-
Scenarios: to bytes
|
14
|
-
| size | unit | limit |
|
15
|
-
| 0 | bytes | 0.0 |
|
16
|
-
| 1023 | bytes | 1023.0 |
|
17
|
-
|
18
|
-
Scenarios: to kilobytes
|
19
|
-
| size | unit | limit |
|
20
|
-
| 1024 | kilobyte | 1.0 |
|
21
|
-
| 1024**2-1 | megabyte | 1.0 |
|
22
|
-
|
23
|
-
Scenarios: to megabytes
|
24
|
-
| size | unit | limit |
|
25
|
-
| 1024**2 | megabyte | 1.0 |
|
26
|
-
| 1024**3-1 | gigabyte | 1.0 |
|
27
|
-
|
28
|
-
Scenarios: to gigabytes
|
29
|
-
| size | unit | limit |
|
30
|
-
| 1024**3 | gigabyte | 1.0 |
|
31
|
-
| 1024**4-1 | gigabytes | 1024.0 |
|
1
|
+
Feature: convert bytes to biggest possible unit
|
2
|
+
|
3
|
+
In order to show file upload errors in human understendable way
|
4
|
+
There should be converter that converts bytes to kilobytes, megabytes, gigabytes.
|
5
|
+
Lolita::Suport::Bytes do that think, it is create by passing bytes, and return unit and values with
|
6
|
+
converted values
|
7
|
+
|
8
|
+
Scenario Outline: convert bytes
|
9
|
+
Given byte converter
|
10
|
+
When I humanize "<size>"
|
11
|
+
Then I should get "<unit>" and "<limit>"
|
12
|
+
|
13
|
+
Scenarios: to bytes
|
14
|
+
| size | unit | limit |
|
15
|
+
| 0 | bytes | 0.0 |
|
16
|
+
| 1023 | bytes | 1023.0 |
|
17
|
+
|
18
|
+
Scenarios: to kilobytes
|
19
|
+
| size | unit | limit |
|
20
|
+
| 1024 | kilobyte | 1.0 |
|
21
|
+
| 1024**2-1 | megabyte | 1.0 |
|
22
|
+
|
23
|
+
Scenarios: to megabytes
|
24
|
+
| size | unit | limit |
|
25
|
+
| 1024**2 | megabyte | 1.0 |
|
26
|
+
| 1024**3-1 | gigabyte | 1.0 |
|
27
|
+
|
28
|
+
Scenarios: to gigabytes
|
29
|
+
| size | unit | limit |
|
30
|
+
| 1024**3 | gigabyte | 1.0 |
|
31
|
+
| 1024**4-1 | gigabytes | 1024.0 |
|
@@ -1,16 +1,16 @@
|
|
1
|
-
Feature: upload file from lolita and manage file attributes
|
2
|
-
|
3
|
-
Files in lolita have name attribute. Any attributes can be changed after file is uploaded.
|
4
|
-
File always is related with some ORM class object.
|
5
|
-
|
6
|
-
Scenario: upload file
|
7
|
-
Given a lolita
|
8
|
-
And a rails
|
9
|
-
And rails application
|
10
|
-
And lolita-file-upload
|
11
|
-
And I visit new post
|
12
|
-
When I upload file normal_file.txt
|
13
|
-
Then I see normal_file
|
14
|
-
And I change file attribute name to my_file
|
15
|
-
And save file
|
1
|
+
Feature: upload file from lolita and manage file attributes
|
2
|
+
|
3
|
+
Files in lolita have name attribute. Any attributes can be changed after file is uploaded.
|
4
|
+
File always is related with some ORM class object.
|
5
|
+
|
6
|
+
Scenario: upload file
|
7
|
+
Given a lolita
|
8
|
+
And a rails
|
9
|
+
And rails application
|
10
|
+
And lolita-file-upload
|
11
|
+
And I visit new post
|
12
|
+
When I upload file normal_file.txt
|
13
|
+
Then I see normal_file
|
14
|
+
And I change file attribute name to my_file
|
15
|
+
And save file
|
16
16
|
Then I see my_file
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require 'generators/helpers/file_helper'
|
2
|
-
module LolitaFileUpload
|
3
|
-
module Generators
|
4
|
-
class AssetsGenerator < Rails::Generators::Base
|
5
|
-
include Lolita::Generators::FileHelper
|
6
|
-
desc "Copy all from public directory to project public directory."
|
7
|
-
def copy_all
|
8
|
-
root=File.expand_path("../../../../",__FILE__)
|
9
|
-
copy_dir("public",:root=>root)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
1
|
+
require 'generators/helpers/file_helper'
|
2
|
+
module LolitaFileUpload
|
3
|
+
module Generators
|
4
|
+
class AssetsGenerator < Rails::Generators::Base
|
5
|
+
include Lolita::Generators::FileHelper
|
6
|
+
desc "Copy all from public directory to project public directory."
|
7
|
+
def copy_all
|
8
|
+
root=File.expand_path("../../../../",__FILE__)
|
9
|
+
copy_dir("public",:root=>root)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
13
|
end
|
@@ -1,19 +1,19 @@
|
|
1
|
-
module LolitaFileUpload
|
2
|
-
module Generators
|
3
|
-
class InstallGenerator < Rails::Generators::Base
|
4
|
-
include Lolita::Generators::FileHelper
|
5
|
-
source_root File.expand_path("../templates", __FILE__)
|
6
|
-
desc "Copy assets and create migrations. "
|
7
|
-
|
8
|
-
|
9
|
-
def copy_assets
|
10
|
-
generate("lolita_file_upload:assets")
|
11
|
-
end
|
12
|
-
|
13
|
-
def copy_migration
|
14
|
-
copy_file "migration.rb", "db/migrate/#{Time.now.strftime("%Y%m%d%H%M%S")}_create_lolita_upload_files.rb"
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
1
|
+
module LolitaFileUpload
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
include Lolita::Generators::FileHelper
|
5
|
+
source_root File.expand_path("../templates", __FILE__)
|
6
|
+
desc "Copy assets and create migrations. "
|
7
|
+
|
8
|
+
|
9
|
+
def copy_assets
|
10
|
+
generate("lolita_file_upload:assets")
|
11
|
+
end
|
12
|
+
|
13
|
+
def copy_migration
|
14
|
+
copy_file "migration.rb", "db/migrate/#{Time.now.strftime("%Y%m%d%H%M%S")}_create_lolita_upload_files.rb"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
class CreateLolitaUploadFiles < ActiveRecord::Migration
|
2
|
-
class << self
|
3
|
-
|
4
|
-
def up
|
5
|
-
create_table :lolita_files, :force=>true do |t|
|
6
|
-
t.string :asset
|
7
|
-
t.string :name
|
8
|
-
t.string :fileable_type
|
9
|
-
t.integer :fileable_id
|
10
|
-
t.string :asset_extension, :limit=>12
|
11
|
-
t.integer :asset_size
|
12
|
-
t.timestamps
|
13
|
-
end
|
14
|
-
|
15
|
-
add_index :lolita_files, [:fileable_type,:fileable_id]
|
16
|
-
add_index :lolita_files, :fileable_type
|
17
|
-
add_index :lolita_files,:asset_size
|
18
|
-
add_index :lolita_files, :created_at
|
19
|
-
end
|
20
|
-
|
21
|
-
def down
|
22
|
-
drop_table :lolita_files
|
23
|
-
end
|
24
|
-
end
|
1
|
+
class CreateLolitaUploadFiles < ActiveRecord::Migration
|
2
|
+
class << self
|
3
|
+
|
4
|
+
def up
|
5
|
+
create_table :lolita_files, :force=>true do |t|
|
6
|
+
t.string :asset
|
7
|
+
t.string :name
|
8
|
+
t.string :fileable_type
|
9
|
+
t.integer :fileable_id
|
10
|
+
t.string :asset_extension, :limit=>12
|
11
|
+
t.integer :asset_size
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
|
15
|
+
add_index :lolita_files, [:fileable_type,:fileable_id]
|
16
|
+
add_index :lolita_files, :fileable_type
|
17
|
+
add_index :lolita_files,:asset_size
|
18
|
+
add_index :lolita_files, :created_at
|
19
|
+
end
|
20
|
+
|
21
|
+
def down
|
22
|
+
drop_table :lolita_files
|
23
|
+
end
|
24
|
+
end
|
25
25
|
end
|
data/lib/lolita-file-upload.rb
CHANGED
@@ -1,37 +1,36 @@
|
|
1
|
-
#TODO add exception if lolita not found, show exception and msg that user should install this gem
|
2
|
-
# if files tab is defined, but there no tab for that, maybe check that through gem.
|
3
|
-
if !defined?(Lolita)
|
4
|
-
require "lolita"
|
5
|
-
end
|
6
|
-
$:<<File.dirname(__FILE__) unless $:.include?(File.dirname(__FILE__))
|
7
|
-
|
8
|
-
I18n.load_path += Dir[File.expand_path("config/locales")+"/**/*.yml"] if defined?(I18n)
|
9
|
-
|
10
|
-
module Lolita
|
11
|
-
module FileUpload
|
12
|
-
end
|
13
|
-
module Support
|
14
|
-
autoload :Bytes, "support/bytes"
|
15
|
-
end
|
16
|
-
|
17
|
-
module Configuration
|
18
|
-
module Tab
|
19
|
-
autoload :Files, "lolita-file-upload/configuration/tab/files"
|
20
|
-
|
21
|
-
|
22
|
-
#
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# There should be the way to connect it on demand when realy multimedia tab is used for resource like
|
1
|
+
#TODO add exception if lolita not found, show exception and msg that user should install this gem
|
2
|
+
# if files tab is defined, but there no tab for that, maybe check that through gem.
|
3
|
+
if !defined?(Lolita)
|
4
|
+
require "lolita"
|
5
|
+
end
|
6
|
+
$:<<File.dirname(__FILE__) unless $:.include?(File.dirname(__FILE__))
|
7
|
+
|
8
|
+
I18n.load_path += Dir[File.expand_path("config/locales")+"/**/*.yml"] if defined?(I18n)
|
9
|
+
|
10
|
+
module Lolita
|
11
|
+
module FileUpload
|
12
|
+
end
|
13
|
+
module Support
|
14
|
+
autoload :Bytes, "support/bytes"
|
15
|
+
end
|
16
|
+
|
17
|
+
module Configuration
|
18
|
+
module Tab
|
19
|
+
autoload :Files, "lolita-file-upload/configuration/tab/files"
|
20
|
+
end
|
21
|
+
# module Field
|
22
|
+
# autoload :Upload, "lolita-file-upload/configuration/field/upload"
|
23
|
+
# end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'lolita-file-upload/module'
|
28
|
+
|
29
|
+
if defined?(Rails)
|
30
|
+
require "lolita-file-upload/rails"
|
31
|
+
end
|
32
|
+
|
33
|
+
# How to connect multimedia engine with lolita resources
|
34
|
+
# Detecting from tabs will not be very good idea because it will load many thing
|
35
|
+
# There should be the way to connect it on demand when realy multimedia tab is used for resource like
|
37
36
|
# lolita/posts/files/new[create,destroy,update, index]
|
@@ -1,58 +1,109 @@
|
|
1
|
-
module Lolita
|
2
|
-
module Configuration
|
3
|
-
module Tab
|
4
|
-
# FileTab extend Lolita default tab with new lolita accessors.
|
5
|
-
# * <tt>extensions</tt> - Array of extension white list
|
6
|
-
# * <tt>maxfilesize</tt> - uploaded file maximums size
|
7
|
-
class Files < Lolita::Configuration::Tab::Base
|
8
|
-
|
9
|
-
lolita_accessor :extensions
|
10
|
-
attr_reader :association, :association_type
|
11
|
-
|
12
|
-
# As any other Lolita::Configuration::Tab this should receive _dbi_ object.
|
13
|
-
# Additional _args_ that may represent methods, for details see Lolita::Configuration::Tab.
|
14
|
-
# And block.
|
15
|
-
def initialize(dbi,*args,&block)
|
16
|
-
@type=:files
|
17
|
-
@
|
18
|
-
@dbi=dbi
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
1
|
+
module Lolita
|
2
|
+
module Configuration
|
3
|
+
module Tab
|
4
|
+
# FileTab extend Lolita default tab with new lolita accessors.
|
5
|
+
# * <tt>extensions</tt> - Array of extension white list
|
6
|
+
# * <tt>maxfilesize</tt> - uploaded file maximums size
|
7
|
+
class Files < Lolita::Configuration::Tab::Base
|
8
|
+
|
9
|
+
lolita_accessor :extensions, :maxfilesize, :filters
|
10
|
+
attr_reader :association, :uploader, :association_type, :editable_fields
|
11
|
+
|
12
|
+
# As any other Lolita::Configuration::Tab this should receive _dbi_ object.
|
13
|
+
# Additional _args_ that may represent methods, for details see Lolita::Configuration::Tab.
|
14
|
+
# And block.
|
15
|
+
def initialize(dbi,*args,&block)
|
16
|
+
@type=:files
|
17
|
+
@filters=[]
|
18
|
+
@dbi=dbi
|
19
|
+
@editable_fields=[]
|
20
|
+
set_default_uploader
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
# NOTE: Filters only limit frontend, backend limit is set in Uploader
|
25
|
+
#
|
26
|
+
# Add another filter or just title for uploader's extension_white_list
|
27
|
+
# ====Example
|
28
|
+
# # using in lolita configuration definition
|
29
|
+
# lolita do
|
30
|
+
# tab(:file) do
|
31
|
+
# title "Pictures"
|
32
|
+
# filters "Images", "png,jpg"
|
33
|
+
# # OR
|
34
|
+
# filters "Pictures"
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
def filters(title=nil, extensions=nil)
|
39
|
+
@filters << {:title => title, :extensions => extensions || self.extension_white_list} if title
|
40
|
+
(@filters.empty? && self.extension_white_list) ? [{:title => self.title, :extensions => self.extension_white_list}] : @filters
|
41
|
+
end
|
42
|
+
|
43
|
+
def uploader name=nil
|
44
|
+
if name
|
45
|
+
@uploader = name.to_sym
|
46
|
+
@association = self.dbi.klass
|
47
|
+
@association_type = :self
|
48
|
+
end
|
49
|
+
@uploader
|
50
|
+
end
|
51
|
+
|
52
|
+
def association name=nil
|
53
|
+
if name
|
54
|
+
@association = self.dbi.associations[name]
|
55
|
+
@association_type = self.dbi.association_macro(@association)
|
56
|
+
@uploader = @association.klass.uploaders.keys.first
|
57
|
+
end
|
58
|
+
@association
|
59
|
+
end
|
60
|
+
|
61
|
+
def association_dbi
|
62
|
+
Lolita::DBI::Base.new self.association.klass
|
63
|
+
end
|
64
|
+
|
65
|
+
def editable_fields *names
|
66
|
+
@editable_fields = names unless names.empty?
|
67
|
+
@editable_fields.empty? ? all_text_fields : @editable_fields
|
68
|
+
end
|
69
|
+
|
70
|
+
def extension_white_list
|
71
|
+
self.association.klass.uploaders[self.uploader].new.extension_white_list
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def all_text_fields
|
77
|
+
self.association_dbi.fields.collect{|field| field[:name] if field[:type] == "string"}.compact
|
78
|
+
end
|
79
|
+
|
80
|
+
def set_default_uploader
|
81
|
+
unless self.dbi.klass.uploaders.empty?
|
82
|
+
@uploader = self.dbi.klass.uploaders.keys.first
|
83
|
+
@association = self.dbi.klass
|
84
|
+
@association_type = :self
|
85
|
+
else
|
86
|
+
set_default_association
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_default_association
|
91
|
+
@association=self.dbi.associations.detect{|k,assoc| !assoc.klass.uploaders.empty? }
|
92
|
+
if @association
|
93
|
+
@association=@association.last
|
94
|
+
@association_type = self.dbi.association_macro(@association)
|
95
|
+
@uploader = @association.klass.uploaders.keys.first
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def validate
|
100
|
+
super
|
101
|
+
unless self.uploader
|
102
|
+
raise "#{self.dbi.klass} has no uploader. Add your custom uploader or use Lolita's built in `has_many :files, :class_name=>'Lolita::Upload::File'`."
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
58
109
|
end
|