projects
/
selectricity-live
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactor the ident_to_quickvote method as a classmethod of the model
[selectricity-live]
/
app
/
models
/
quick_vote.rb
diff --git
a/app/models/quick_vote.rb
b/app/models/quick_vote.rb
index 6259784bfbaf1bc847ad8e67b6fad04a2722cf45..5f566c6eb1e6575e1f8f6a7845e67ba21d963c53 100644
(file)
--- a/
app/models/quick_vote.rb
+++ b/
app/models/quick_vote.rb
@@
-74,4
+74,15
@@
class QuickVote < Election
end
end
+
+ ### Convert a shortname or id into a QuickVote
+ def self.ident_to_quickvote(ident)
+ if ident.match(/^\d+$/)
+ quickvote = QuickVote.find(ident)
+ else
+ quickvote = QuickVote.find_all(["name = ?", ident])[0]
+ end
+
+ return quickvote
+ end
end
end
Benjamin Mako Hill
||
Want to submit a patch?