Gentoo Archives: gentoo-commits

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/council-webapp:master commit in: site/app/models/
Date: Mon, 01 Aug 2011 14:39:02
Message-Id: 17a5bb7652293de6b1129df9cc7cbd752c676394.betelgeuse@gentoo
1 commit: 17a5bb7652293de6b1129df9cc7cbd752c676394
2 Author: Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
3 AuthorDate: Tue Jul 26 15:16:57 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 26 15:16:57 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=17a5bb76
7
8 Use hobo scopes where possible
9
10 Not Model.find :conditions => { ... }
11
12 ---
13 site/app/models/agenda.rb | 6 +++---
14 1 files changed, 3 insertions(+), 3 deletions(-)
15
16 diff --git a/site/app/models/agenda.rb b/site/app/models/agenda.rb
17 index 29c57f5..4039d0c 100644
18 --- a/site/app/models/agenda.rb
19 +++ b/site/app/models/agenda.rb
20 @@ -77,7 +77,7 @@ class Agenda < ActiveRecord::Base
21 def self.update_voting_options(options)
22 agenda = Agenda.current
23 options.each do |item_info|
24 - item = AgendaItem.first :conditions => { :agenda_id => agenda, :title => item_info.first }
25 + item = AgendaItem.agenda_id_is(agenda).title_is(item_info.first).first
26 item.update_voting_options(item_info[1])
27 end
28 end
29 @@ -85,10 +85,10 @@ class Agenda < ActiveRecord::Base
30 def self.process_results(results)
31 agenda = Agenda.current
32 for item_title in results.keys
33 - item = AgendaItem.first :conditions => { :agenda_id => agenda, :title => item_title }
34 + item = AgendaItem.agenda_id_is(agenda.id).title_is(item_title).first
35 votes = results[item_title]
36 for voter in votes.keys
37 - option = VotingOption.first :conditions => { :agenda_item_id => item.id, :description => votes[voter] }
38 + option = VotingOption.agenda_item_id_is(item.id).description_is(votes[voter]).first
39 user = ::User.find_by_irc_nick voter
40 Vote.vote_for_option(user, option, true)
41 end