Class: Sequel::Model
- Inherits:
-
Object
- Object
- Sequel::Model
- Defined in:
- lib/zen/model/methods.rb
Overview
:nodoc:
Direct Known Subclasses
Categories::Model::Category, Categories::Model::CategoryGroup, Comments::Model::Comment, Comments::Model::CommentStatus, CustomFields::Model::CustomField, CustomFields::Model::CustomFieldGroup, CustomFields::Model::CustomFieldMethod, CustomFields::Model::CustomFieldType, CustomFields::Model::CustomFieldValue, Menus::Model::Menu, Menus::Model::MenuItem, Sections::Model::Section, Sections::Model::SectionEntry, Sections::Model::SectionEntryStatus, Settings::Model::Setting, Users::Model::Permission, Users::Model::User, Users::Model::UserGroup, Users::Model::UserStatus
Class Method Summary (collapse)
-
+ (Hash) pk_hash(column)
Retrieves all primary values and an optional column and returns the results as an array of hashes in which the keys of these hashes are the IDs and the values the values of the specified column.
Class Method Details
+ (Hash) pk_hash(column)
Retrieves all primary values and an optional column and returns the results as an array of hashes in which the keys of these hashes are the IDs and the values the values of the specified column. This array can be used when creating
17 18 19 20 21 22 23 24 25 |
# File 'lib/zen/model/methods.rb', line 17 def self.pk_hash(column) hash = {} self.select(:id, column.to_sym).each do |row| hash[row.id] = row.send(column) end return hash end |