attachable 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +10 -0
- data/lib/attachable.rb +5 -9
- data/lib/attachable/version.rb +1 -1
- metadata +1 -1
data/Rakefile
CHANGED
data/lib/attachable.rb
CHANGED
@@ -15,17 +15,13 @@ module Attachable
|
|
15
15
|
cattr_accessor :attachment_file_prefix
|
16
16
|
self.attachment_file_prefix = (options[:file_prefix] || :file).to_s
|
17
17
|
|
18
|
-
# Setup the default scope so the file data isn't included by default
|
19
|
-
|
18
|
+
# Setup the default scope so the file data isn't included by default.
|
19
|
+
# Generate the default scope, which includes every column except for the data column.
|
20
|
+
# We use this so queries, by default, don't include the file data which could be quite large.
|
21
|
+
default_scope { select(column_names.reject { |n| n == "#{attachment_file_prefix}_data" }.collect {|n| "#{table_name}.#{n}" }.join(',')) }
|
20
22
|
|
21
23
|
# Include all the important stuff
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
# Generate the default scope, which includes every column except for the data column.
|
26
|
-
# We use this so queries, by default, don't include the file data which could be quite large.
|
27
|
-
def attachable_scope
|
28
|
-
select(column_names.reject { |n| n == "#{attachment_file_prefix}_data" }.collect {|n| "#{table_name}.#{n}" }.join(','))
|
24
|
+
include InstanceMethods
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
data/lib/attachable/version.rb
CHANGED