Commit 4352c377b0d2b9840126dbeaf8082c1771ced54d
Committed by
Braulio Bhavamitra
1 parent
64eda093
Exists in
staging
and in
39 other branches
rails4: stick with ruby 1.9 for lambda syntax bug
Signed-off-by: Braulio Bhavamitra <brauliobo@gmail.com> Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
Showing
19 changed files
with
89 additions
and
89 deletions
Show diff stats
.travis.yml
app/models/article.rb
... | ... | @@ -74,7 +74,7 @@ class Article < ActiveRecord::Base |
74 | 74 | |
75 | 75 | has_many :comments, :class_name => 'Comment', :foreign_key => 'source_id', :dependent => :destroy, :order => 'created_at asc' |
76 | 76 | |
77 | - has_many :article_categorizations, -> { where 'articles_categories.virtual = ?', false } | |
77 | + has_many :article_categorizations, ->{ where 'articles_categories.virtual = ?', false } | |
78 | 78 | has_many :categories, :through => :article_categorizations |
79 | 79 | |
80 | 80 | has_many :article_categorizations_including_virtual, :class_name => 'ArticleCategorization' |
... | ... | @@ -126,11 +126,11 @@ class Article < ActiveRecord::Base |
126 | 126 | |
127 | 127 | xss_terminate :only => [ :name ], :on => 'validation', :with => 'white_list' |
128 | 128 | |
129 | - scope :in_category, -> (category) { | |
129 | + scope :in_category, ->(category) { | |
130 | 130 | includes('categories_including_virtual').where('categories.id' => category.id) |
131 | 131 | } |
132 | 132 | |
133 | - scope :by_range, -> (range) { | |
133 | + scope :by_range, ->(range) { | |
134 | 134 | where 'articles.published_at BETWEEN :start_date AND :end_date', { start_date: range.first, end_date: range.last } |
135 | 135 | } |
136 | 136 | |
... | ... | @@ -254,16 +254,16 @@ class Article < ActiveRecord::Base |
254 | 254 | |
255 | 255 | # retrieves all articles belonging to the given +profile+ that are not |
256 | 256 | # sub-articles of any other article. |
257 | - scope :top_level_for, -> (profile) { | |
257 | + scope :top_level_for, ->(profile) { | |
258 | 258 | where 'parent_id is null and profile_id = ?', profile.id |
259 | 259 | } |
260 | 260 | |
261 | - scope :is_public, -> { | |
261 | + scope :is_public, ->{ | |
262 | 262 | joins(:profile). |
263 | 263 | where("advertise = ? AND published = ? AND profiles.visible = ? AND profiles.public_profile = ?", true, true, true, true) |
264 | 264 | } |
265 | 265 | |
266 | - scope :more_recent, -> { | |
266 | + scope :more_recent, ->{ | |
267 | 267 | order('articles.published_at desc, articles.id desc') |
268 | 268 | .where("advertise = ? AND published = ? AND profiles.visible = ? AND profiles.public_profile = ? AND |
269 | 269 | ((articles.type != ?) OR articles.type is NULL)", |
... | ... | @@ -276,8 +276,8 @@ class Article < ActiveRecord::Base |
276 | 276 | paginate(:order => 'comments_count DESC', :page => 1, :per_page => limit) |
277 | 277 | end |
278 | 278 | |
279 | - scope :more_popular, -> { order 'hits DESC' } | |
280 | - scope :relevant_as_recent, -> { | |
279 | + scope :more_popular, ->{ order 'hits DESC' } | |
280 | + scope :relevant_as_recent, ->{ | |
281 | 281 | where "(articles.type != 'UploadedFile' and articles.type != 'RssFeed' and articles.type != 'Blog') OR articles.type is NULL" |
282 | 282 | } |
283 | 283 | |
... | ... | @@ -408,7 +408,7 @@ class Article < ActiveRecord::Base |
408 | 408 | self.translations.map(&:language) |
409 | 409 | end |
410 | 410 | |
411 | - scope :native_translations, -> { where :translation_of_id => nil } | |
411 | + scope :native_translations, ->{ where :translation_of_id => nil } | |
412 | 412 | |
413 | 413 | def translatable? |
414 | 414 | false |
... | ... | @@ -487,19 +487,19 @@ class Article < ActiveRecord::Base |
487 | 487 | ['TextArticle', 'TextileArticle', 'TinyMceArticle'] |
488 | 488 | end |
489 | 489 | |
490 | - scope :published, -> { where 'articles.published = ?', true } | |
491 | - scope :folders, -> (profile) { where 'articles.type IN (?)', profile.folder_types } | |
492 | - scope :no_folders, -> (profile) { where 'articles.type NOT IN (?)', profile.folder_types } | |
493 | - scope :galleries, -> { where "articles.type IN ('Gallery')" } | |
494 | - scope :images, -> { where :is_image => true } | |
495 | - scope :no_images, -> { where :is_image => false } | |
496 | - scope :text_articles, -> { where 'articles.type IN (?)', text_article_types } | |
497 | - scope :files, -> { where :type => 'UploadedFile' } | |
498 | - scope :with_types, -> (types) { where 'articles.type IN (?)', types } | |
490 | + scope :published, ->{ where 'articles.published = ?', true } | |
491 | + scope :folders, ->(profile) { where 'articles.type IN (?)', profile.folder_types } | |
492 | + scope :no_folders, ->(profile) { where 'articles.type NOT IN (?)', profile.folder_types } | |
493 | + scope :galleries, ->{ where "articles.type IN ('Gallery')" } | |
494 | + scope :images, ->{ where :is_image => true } | |
495 | + scope :no_images, ->{ where :is_image => false } | |
496 | + scope :text_articles, ->{ where 'articles.type IN (?)', text_article_types } | |
497 | + scope :files, ->{ where :type => 'UploadedFile' } | |
498 | + scope :with_types, ->(types) { where 'articles.type IN (?)', types } | |
499 | 499 | |
500 | - scope :more_popular, -> { order 'hits DESC' } | |
501 | - scope :more_comments, -> { order "comments_count DESC" } | |
502 | - scope :more_recent, -> { order "created_at DESC" } | |
500 | + scope :more_popular, ->{ order 'hits DESC' } | |
501 | + scope :more_comments, ->{ order "comments_count DESC" } | |
502 | + scope :more_recent, ->{ order "created_at DESC" } | |
503 | 503 | |
504 | 504 | scope :display_filter, lambda {|user, profile| |
505 | 505 | return published if (user.nil? && profile && profile.public?) | ... | ... |
app/models/category.rb
... | ... | @@ -15,11 +15,11 @@ class Category < ActiveRecord::Base |
15 | 15 | belongs_to :environment |
16 | 16 | |
17 | 17 | # Finds all top level categories for a given environment. |
18 | - scope :top_level_for, -> (environment) { | |
18 | + scope :top_level_for, ->(environment) { | |
19 | 19 | where 'parent_id is null and environment_id = ?', environment.id |
20 | 20 | } |
21 | 21 | |
22 | - scope :on_level, -> (parent) { where :parent_id => parent } | |
22 | + scope :on_level, ->(parent) { where :parent_id => parent } | |
23 | 23 | |
24 | 24 | acts_as_filesystem |
25 | 25 | |
... | ... | @@ -46,7 +46,7 @@ class Category < ActiveRecord::Base |
46 | 46 | display_color = nil if display_color.blank? |
47 | 47 | end |
48 | 48 | |
49 | - scope :from_types, -> (types) { | |
49 | + scope :from_types, ->(types) { | |
50 | 50 | if types.select{ |t| t.blank? }.empty? then |
51 | 51 | where(type: types) else |
52 | 52 | where("type IN (?) OR type IS NULL", types.reject{ |t| t.blank? }) end | ... | ... |
app/models/event.rb
... | ... | @@ -34,19 +34,19 @@ class Event < Article |
34 | 34 | end |
35 | 35 | end |
36 | 36 | |
37 | - scope :by_day, -> (date) { | |
37 | + scope :by_day, ->(date) { | |
38 | 38 | where('start_date >= :start_date AND start_date <= :end_date AND end_date IS NULL OR (start_date <= :end_date AND end_date >= :start_date)', |
39 | 39 | start_date: date.beginning_of_day, end_date: date.end_of_day). |
40 | 40 | order('start_date ASC') |
41 | 41 | } |
42 | 42 | |
43 | - scope :next_events_from_month, -> (date) { | |
43 | + scope :next_events_from_month, ->(date) { | |
44 | 44 | date_temp = date.strftime("%Y-%m-%d") |
45 | 45 | order('start_date ASC') |
46 | 46 | .where("start_date >= ?","#{date_temp}") |
47 | 47 | } |
48 | 48 | |
49 | - scope :by_month, -> (date) { | |
49 | + scope :by_month, ->(date) { | |
50 | 50 | order('start_date ASC') |
51 | 51 | .where("EXTRACT(YEAR FROM start_date) = ? AND EXTRACT(MONTH FROM start_date) = ?", date.year, date.month) |
52 | 52 | } |
... | ... | @@ -69,7 +69,7 @@ class Event < Article |
69 | 69 | 'event' |
70 | 70 | end |
71 | 71 | |
72 | - scope :by_range, -> (range) { | |
72 | + scope :by_range, ->(range) { | |
73 | 73 | where('start_date BETWEEN :start_day AND :end_day OR end_date BETWEEN :start_day AND :end_day', |
74 | 74 | {:start_day => range.first, :end_day => range.last}) |
75 | 75 | } | ... | ... |
app/models/person.rb
... | ... | @@ -16,24 +16,24 @@ class Person < Profile |
16 | 16 | acts_as_trackable :after_add => Proc.new {|p,t| notify_activity(t)} |
17 | 17 | acts_as_accessor |
18 | 18 | |
19 | - scope :members_of, -> (resources) { | |
19 | + scope :members_of, ->(resources) { | |
20 | 20 | resources = Array(resources) |
21 | 21 | conditions = resources.map {|resource| "role_assignments.resource_type = '#{resource.class.base_class.name}' AND role_assignments.resource_id = #{resource.id || -1}"}.join(' OR ') |
22 | 22 | select('DISTINCT profiles.*').joins(:role_assignments).where([conditions]) |
23 | 23 | } |
24 | 24 | |
25 | - scope :not_members_of, -> (resources) { | |
25 | + scope :not_members_of, ->(resources) { | |
26 | 26 | resources = Array(resources) |
27 | 27 | conditions = resources.map {|resource| "role_assignments.resource_type = '#{resource.class.base_class.name}' AND role_assignments.resource_id = #{resource.id || -1}"}.join(' OR ') |
28 | 28 | select('DISTINCT profiles.*').where('"profiles"."id" NOT IN (SELECT DISTINCT profiles.id FROM "profiles" INNER JOIN "role_assignments" ON "role_assignments"."accessor_id" = "profiles"."id" AND "role_assignments"."accessor_type" = (\'Profile\') WHERE "profiles"."type" IN (\'Person\') AND (%s))' % conditions) |
29 | 29 | } |
30 | 30 | |
31 | - scope :by_role, -> (roles) { | |
31 | + scope :by_role, ->(roles) { | |
32 | 32 | roles = Array(roles) |
33 | 33 | select('DISTINCT profiles.*').joins(:role_assignments).where('role_assignments.role_id IN (?)', roles) |
34 | 34 | } |
35 | 35 | |
36 | - scope :not_friends_of, -> (resources) { | |
36 | + scope :not_friends_of, ->(resources) { | |
37 | 37 | resources = Array(resources) |
38 | 38 | select('DISTINCT profiles.*').where('"profiles"."id" NOT IN (SELECT DISTINCT profiles.id FROM "profiles" INNER JOIN "friendships" ON "friendships"."person_id" = "profiles"."id" WHERE "friendships"."friend_id" IN (%s))' % resources.map(&:id)) |
39 | 39 | } |
... | ... | @@ -70,7 +70,7 @@ class Person < Profile |
70 | 70 | has_many :friendships, :dependent => :destroy |
71 | 71 | has_many :friends, :class_name => 'Person', :through => :friendships |
72 | 72 | |
73 | - scope :online, -> { | |
73 | + scope :online, ->{ | |
74 | 74 | joins(:user).where("users.chat_status != '' AND users.chat_status_at >= ?", DateTime.now - User.expires_chat_status_every.minutes) |
75 | 75 | } |
76 | 76 | |
... | ... | @@ -89,27 +89,27 @@ class Person < Profile |
89 | 89 | has_and_belongs_to_many :articles_with_access, :class_name => 'Article', :join_table => 'article_privacy_exceptions' |
90 | 90 | |
91 | 91 | has_many :suggested_profiles, class_name: 'ProfileSuggestion', foreign_key: :person_id, order: 'score DESC', dependent: :destroy |
92 | - has_many :suggested_people, -> { | |
92 | + has_many :suggested_people, ->{ | |
93 | 93 | where 'profile_suggestions.suggestion_type = ? AND profile_suggestions.enabled = ?', 'Person', true |
94 | 94 | }, through: :suggested_profiles, source: :suggestion |
95 | - has_many :suggested_communities, -> { | |
95 | + has_many :suggested_communities, ->{ | |
96 | 96 | where 'profile_suggestions.suggestion_type = ? AND profile_suggestions.enabled = ?', 'Community', true |
97 | 97 | }, through: :suggested_profiles, source: :suggestion |
98 | 98 | |
99 | - scope :more_popular, -> { order 'friends_count DESC' } | |
99 | + scope :more_popular, ->{ order 'friends_count DESC' } | |
100 | 100 | |
101 | - scope :abusers, -> { | |
101 | + scope :abusers, ->{ | |
102 | 102 | joins(:abuse_complaints).where('tasks.status = 3').select('DISTINCT profiles.*') |
103 | 103 | } |
104 | - scope :non_abusers, -> { | |
104 | + scope :non_abusers, ->{ | |
105 | 105 | select("DISTINCT profiles.*"). |
106 | 106 | joins("LEFT JOIN tasks ON profiles.id = tasks.requestor_id AND tasks.type='AbuseComplaint'"). |
107 | 107 | where("tasks.status != 3 OR tasks.id is NULL") |
108 | 108 | } |
109 | 109 | |
110 | - scope :admins, -> { joins(:role_assignments => :role).where('roles.key = ?', 'environment_administrator') } | |
111 | - scope :activated, -> { joins(:user).where('users.activation_code IS NULL AND users.activated_at IS NOT NULL') } | |
112 | - scope :deactivated, -> { joins(:user).where('NOT (users.activation_code IS NULL AND users.activated_at IS NOT NULL)') } | |
110 | + scope :admins, ->{ joins(:role_assignments => :role).where('roles.key = ?', 'environment_administrator') } | |
111 | + scope :activated, ->{ joins(:user).where('users.activation_code IS NULL AND users.activated_at IS NOT NULL') } | |
112 | + scope :deactivated, ->{ joins(:user).where('NOT (users.activation_code IS NULL AND users.activated_at IS NOT NULL)') } | |
113 | 113 | |
114 | 114 | after_destroy do |person| |
115 | 115 | Friendship.where(friend_id: person.id).each{ |friendship| friendship.destroy } | ... | ... |
app/models/product.rb
... | ... | @@ -52,7 +52,7 @@ class Product < ActiveRecord::Base |
52 | 52 | |
53 | 53 | scope :more_recent, :order => "created_at DESC" |
54 | 54 | |
55 | - scope :from_category, -> (category) { | |
55 | + scope :from_category, ->(category) { | |
56 | 56 | joins(:product_category).where('categories.path LIKE ?', "%#{category.slug}%") if category |
57 | 57 | } |
58 | 58 | ... | ... |
app/models/product_category.rb
... | ... | @@ -6,14 +6,14 @@ class ProductCategory < Category |
6 | 6 | attr_accessible :name, :parent, :environment |
7 | 7 | |
8 | 8 | scope :unique, :select => 'DISTINCT ON (path) categories.*' |
9 | - scope :by_enterprise, -> (enterprise) { | |
9 | + scope :by_enterprise, ->(enterprise) { | |
10 | 10 | joins(:products). |
11 | 11 | where('products.profile_id = ?', enterprise.id) |
12 | 12 | } |
13 | - scope :by_environment, -> (environment) { | |
13 | + scope :by_environment, ->(environment) { | |
14 | 14 | where 'environment_id = ?', environment.id |
15 | 15 | } |
16 | - scope :unique_by_level, -> (level) { | |
16 | + scope :unique_by_level, ->(level) { | |
17 | 17 | select "DISTINCT ON (filtered_category) split_part(path, '/', #{level}) AS filtered_category, categories.*" |
18 | 18 | } |
19 | 19 | ... | ... |
app/models/profile.rb
... | ... | @@ -87,28 +87,28 @@ class Profile < ActiveRecord::Base |
87 | 87 | |
88 | 88 | include Noosfero::Plugin::HotSpot |
89 | 89 | |
90 | - scope :memberships_of, -> (person) { | |
90 | + scope :memberships_of, ->(person) { | |
91 | 91 | select('DISTINCT profiles.*'). |
92 | 92 | joins(:role_assignments). |
93 | 93 | where('role_assignments.accessor_type = ? AND role_assignments.accessor_id = ?', person.class.base_class.name, person.id) |
94 | 94 | } |
95 | 95 | #FIXME: these will work only if the subclass is already loaded |
96 | - scope :enterprises, -> { | |
96 | + scope :enterprises, ->{ | |
97 | 97 | where((Enterprise.send(:subclasses).map(&:name) << 'Enterprise').map { |klass| "profiles.type = '#{klass}'"}.join(" OR ")) |
98 | 98 | } |
99 | - scope :communities, -> { | |
99 | + scope :communities, ->{ | |
100 | 100 | where((Community.send(:subclasses).map(&:name) << 'Community').map { |klass| "profiles.type = '#{klass}'"}.join(" OR ")) |
101 | 101 | } |
102 | - scope :templates, -> (template_id = nil) { | |
102 | + scope :templates, ->(template_id = nil) { | |
103 | 103 | s = where is_template: true |
104 | 104 | s = s.where id: template_id if template_id |
105 | 105 | s |
106 | 106 | } |
107 | 107 | |
108 | - scope :with_templates, -> (templates) { | |
108 | + scope :with_templates, ->(templates) { | |
109 | 109 | where template_id: templates |
110 | 110 | } |
111 | - scope :no_templates, -> { where is_template: false } | |
111 | + scope :no_templates, ->{ where is_template: false } | |
112 | 112 | |
113 | 113 | def members |
114 | 114 | scopes = plugins.dispatch_scopes(:organization_members, self) |
... | ... | @@ -141,10 +141,10 @@ class Profile < ActiveRecord::Base |
141 | 141 | Profile.column_names.map{|n| [Profile.table_name, n].join('.')}.join(',') |
142 | 142 | end |
143 | 143 | |
144 | - scope :visible, -> { where visible: true, secret: false } | |
145 | - scope :disabled, -> { where visible: false } | |
146 | - scope :is_public, -> { where visible: true, public_profile: true, secret: false } | |
147 | - scope :enabled, -> { where enabled: true } | |
144 | + scope :visible, ->{ where visible: true, secret: false } | |
145 | + scope :disabled, ->{ where visible: false } | |
146 | + scope :is_public, ->{ where visible: true, public_profile: true, secret: false } | |
147 | + scope :enabled, ->{ where enabled: true } | |
148 | 148 | |
149 | 149 | # Subclasses must override this method |
150 | 150 | scope :more_popular |
... | ... | @@ -245,7 +245,7 @@ class Profile < ActiveRecord::Base |
245 | 245 | end |
246 | 246 | end |
247 | 247 | |
248 | - has_many :profile_categorizations, -> { where 'categories_profiles.virtual = ?', false } | |
248 | + has_many :profile_categorizations, ->{ where 'categories_profiles.virtual = ?', false } | |
249 | 249 | has_many :categories, :through => :profile_categorizations |
250 | 250 | |
251 | 251 | has_many :profile_categorizations_including_virtual, :class_name => 'ProfileCategorization' | ... | ... |
app/models/scrap.rb
... | ... | @@ -18,9 +18,9 @@ class Scrap < ActiveRecord::Base |
18 | 18 | after_create :create_activity |
19 | 19 | after_update :update_activity |
20 | 20 | |
21 | - scope :all_scraps, -> (profile) { limit(30).where("receiver_id = ? OR sender_id = ?", profile, profile) } | |
21 | + scope :all_scraps, ->(profile) { limit(30).where("receiver_id = ? OR sender_id = ?", profile, profile) } | |
22 | 22 | |
23 | - scope :not_replies, -> { where scrap_id: nil } | |
23 | + scope :not_replies, ->{ where scrap_id: nil } | |
24 | 24 | |
25 | 25 | track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.sender != s.receiver && s.sender != s.top_root.receiver}, :custom_target => :action_tracker_target |
26 | 26 | ... | ... |
app/models/task.rb
... | ... | @@ -236,16 +236,16 @@ class Task < ActiveRecord::Base |
236 | 236 | end |
237 | 237 | end |
238 | 238 | |
239 | - scope :pending, -> { where status: Task::Status::ACTIVE } | |
240 | - scope :hidden, -> { where status: Task::Status::HIDDEN } | |
241 | - scope :finished, -> { where status: Task::Status::FINISHED } | |
242 | - scope :canceled, -> { where status: Task::Status::CANCELLED } | |
243 | - scope :closed, -> { where status: [Task::Status::CANCELLED, Task::Status::FINISHED] } | |
244 | - scope :opened, -> { where status: [Task::Status::ACTIVE, Task::Status::HIDDEN] } | |
245 | - scope :of, -> (type) { where "type LIKE ?", type if type } | |
246 | - scope :order_by, -> (attribute, ord) { order "#{attribute} #{ord}" } | |
247 | - scope :like, -> (field, value) { where "LOWER(#{field}) LIKE ?", "%#{value.downcase}%" if value } | |
248 | - scope :pending_all, -> (profile, filter_type, filter_text) { | |
239 | + scope :pending, ->{ where status: Task::Status::ACTIVE } | |
240 | + scope :hidden, ->{ where status: Task::Status::HIDDEN } | |
241 | + scope :finished, ->{ where status: Task::Status::FINISHED } | |
242 | + scope :canceled, ->{ where status: Task::Status::CANCELLED } | |
243 | + scope :closed, ->{ where status: [Task::Status::CANCELLED, Task::Status::FINISHED] } | |
244 | + scope :opened, ->{ where status: [Task::Status::ACTIVE, Task::Status::HIDDEN] } | |
245 | + scope :of, ->(type) { where "type LIKE ?", type if type } | |
246 | + scope :order_by, ->(attribute, ord) { order "#{attribute} #{ord}" } | |
247 | + scope :like, ->(field, value) { where "LOWER(#{field}) LIKE ?", "%#{value.downcase}%" if value } | |
248 | + scope :pending_all, ->(profile, filter_type, filter_text) { | |
249 | 249 | self.to(profile).without_spam.pending.of(filter_type).like('data', filter_text) |
250 | 250 | } |
251 | 251 | |
... | ... | @@ -306,7 +306,7 @@ class Task < ActiveRecord::Base |
306 | 306 | # specified code AND with status = Task::Status::ACTIVE. |
307 | 307 | # |
308 | 308 | # Can be used in subclasses to find only their instances. |
309 | - scope :from_code, -> (code) { where code: code, status: Task::Status::ACTIVE } | |
309 | + scope :from_code, ->(code) { where code: code, status: Task::Status::ACTIVE } | |
310 | 310 | |
311 | 311 | class << self |
312 | 312 | ... | ... |
plugins/bsc/lib/bsc_plugin/contract.rb
... | ... | @@ -8,8 +8,8 @@ class BscPlugin::Contract < ActiveRecord::Base |
8 | 8 | |
9 | 9 | belongs_to :bsc, :class_name => 'BscPlugin::Bsc' |
10 | 10 | |
11 | - named_scope :status, -> (status_list) { where 'status in (?)', status_list if status_list.present? } | |
12 | - named_scope :sorted_by, -> (sorter, direction) { order "#{sorter} #{direction}" } | |
11 | + named_scope :status, ->(status_list) { where 'status in (?)', status_list if status_list.present? } | |
12 | + named_scope :sorted_by, ->(sorter, direction) { order "#{sorter} #{direction}" } | |
13 | 13 | |
14 | 14 | before_create do |contract| |
15 | 15 | contract.created_at ||= Time.now.utc | ... | ... |
plugins/comment_group/lib/ext/comment.rb
... | ... | @@ -2,9 +2,9 @@ require_dependency 'comment' |
2 | 2 | |
3 | 3 | class Comment |
4 | 4 | |
5 | - scope :without_group, -> { where group_id: nil } | |
5 | + scope :without_group, ->{ where group_id: nil } | |
6 | 6 | |
7 | - scope :in_group, -> (group_id) { where 'group_id = ?', group_id } | |
7 | + scope :in_group, ->(group_id) { where 'group_id = ?', group_id } | |
8 | 8 | |
9 | 9 | attr_accessible :group_id |
10 | 10 | ... | ... |
plugins/custom_forms/lib/custom_forms_plugin/form.rb
... | ... | @@ -26,9 +26,9 @@ class CustomFormsPlugin::Form < ActiveRecord::Base |
26 | 26 | tasks.each {|task| task.cancel} |
27 | 27 | end |
28 | 28 | |
29 | - scope :from_profile, -> (profile) { where profile_id: profile.id } | |
30 | - scope :on_memberships, -> { where on_membership: true, for_admission: false } | |
31 | - scope :for_admissions, -> { where for_admission: true } | |
29 | + scope :from_profile, ->(profile) { where profile_id: profile.id } | |
30 | + scope :on_memberships, ->{ where on_membership: true, for_admission: false } | |
31 | + scope :for_admissions, ->{ where for_admission: true } | |
32 | 32 | =begin |
33 | 33 | scope :accessible_to lambda do |profile| |
34 | 34 | #TODO should verify is profile is associated with the form owner | ... | ... |
plugins/custom_forms/lib/custom_forms_plugin/membership_survey.rb
... | ... | @@ -5,7 +5,7 @@ class CustomFormsPlugin::MembershipSurvey < Task |
5 | 5 | |
6 | 6 | include CustomFormsPlugin::Helper |
7 | 7 | |
8 | - scope :from_profile, -> (profile) { where requestor_id: profile.id } | |
8 | + scope :from_profile, ->(profile) { where requestor_id: profile.id } | |
9 | 9 | |
10 | 10 | def perform |
11 | 11 | form = CustomFormsPlugin::Form.find(form_id) | ... | ... |
plugins/people_block/lib/ext/person.rb
plugins/spaminator/lib/spaminator_plugin/report.rb
... | ... | @@ -8,7 +8,7 @@ class SpaminatorPlugin::Report < ActiveRecord::Base |
8 | 8 | |
9 | 9 | attr_accessible :environment |
10 | 10 | |
11 | - scope :from_environment, -> (environment) { where :environment_id => environment } | |
11 | + scope :from_environment, ->(environment) { where :environment_id => environment } | |
12 | 12 | |
13 | 13 | after_initialize do |report| |
14 | 14 | report.failed = {:people => [], :comments => []} if report.failed.blank? | ... | ... |
plugins/sub_organizations/lib/ext/organization.rb
... | ... | @@ -13,17 +13,17 @@ class Organization |
13 | 13 | |
14 | 14 | FIELDS << 'sub_organizations_plugin_parent_to_be' |
15 | 15 | |
16 | - scope :children, -> (parent) { | |
16 | + scope :children, ->(parent) { | |
17 | 17 | joins("inner join sub_organizations_plugin_relations as relations on profiles.id=relations.child_id"). |
18 | 18 | where("relations.parent_id = ?", parent.id) |
19 | 19 | } |
20 | 20 | |
21 | - scope :parents, -> (*children) { | |
21 | + scope :parents, ->(*children) { | |
22 | 22 | joins("inner join sub_organizations_plugin_relations as relations on profiles.id=relations.parent_id"). |
23 | 23 | where("relations.child_id in (?)", children.map(&:id)) |
24 | 24 | } |
25 | 25 | |
26 | - scope :pending_children, -> (parent) { | |
26 | + scope :pending_children, ->(parent) { | |
27 | 27 | select("distinct profiles.*"). |
28 | 28 | joins("inner join sub_organizations_plugin_approve_paternity_relations as relations on profiles.id=relations.child_id inner join tasks on relations.task_id=tasks.id"). |
29 | 29 | where("relations.parent_id = ? AND tasks.status = 1", parent.id) | ... | ... |
vendor/plugins/access_control/lib/role_assignment.rb
... | ... | @@ -9,11 +9,11 @@ class RoleAssignment < ActiveRecord::Base |
9 | 9 | validates_presence_of :role, :accessor |
10 | 10 | |
11 | 11 | track_actions :join_community, :after_create, :keep_params => ["resource.name", "resource.url", "resource.profile_custom_icon"], |
12 | - if: -> (x) { x.resource.is_a?(Community) && x.accessor.role_assignments.where(resource_id: x.resource.id, resource_type: 'Profile').count == 1 }, | |
12 | + if: ->(x) { x.resource.is_a?(Community) && x.accessor.role_assignments.where(resource_id: x.resource.id, resource_type: 'Profile').count == 1 }, | |
13 | 13 | :custom_user => :accessor, :custom_target => :resource |
14 | 14 | |
15 | 15 | track_actions :add_member_in_community, :after_create, |
16 | - if: -> (x) { x.resource.is_a?(Community) && x.accessor.role_assignments.where(resource_id: x.resource.id, resource_type: 'Profile').count == 1 }, | |
16 | + if: ->(x) { x.resource.is_a?(Community) && x.accessor.role_assignments.where(resource_id: x.resource.id, resource_type: 'Profile').count == 1 }, | |
17 | 17 | :custom_user => :accessor, :custom_target => :resource |
18 | 18 | |
19 | 19 | def has_permission?(perm, res) | ... | ... |
vendor/plugins/kandadaboggu-vote_fu/lib/models/vote.rb
1 | 1 | class Vote < ActiveRecord::Base |
2 | 2 | |
3 | - scope :for_voter, -> (*args) { | |
3 | + scope :for_voter, ->(*args) { | |
4 | 4 | where "voter_id = ? AND voter_type = ?", args.first.id, args.first.class.base_class.name |
5 | 5 | } |
6 | - scope :for_voteable, -> (*args) { | |
6 | + scope :for_voteable, ->(*args) { | |
7 | 7 | where "voteable_id = ? AND voteable_type = ?", args.first.id, args.first.class.base_class.name |
8 | 8 | } |
9 | - scope :recent, -> (*args) { | |
9 | + scope :recent, ->(*args) { | |
10 | 10 | where "created_at > ?", (args.first || 2.weeks.ago).to_s(:db) |
11 | 11 | } |
12 | - scope :descending, -> { order "created_at DESC" } | |
12 | + scope :descending, ->{ order "created_at DESC" } | |
13 | 13 | |
14 | 14 | # NOTE: Votes belong to the "voteable" interface, and also to voters |
15 | 15 | belongs_to :voteable, :polymorphic => true | ... | ... |