Class: ProconBypassMan::Web::Setting
- Defined in:
- lib/procon_bypass_man/web/models/setting.rb
Class Method Summary collapse
Methods inherited from BaseModel
column_names, column_names=, count, db, #initialize, table_name, #table_name, table_name=, #update!
Constructor Details
This class inherits a constructor from ProconBypassMan::Web::BaseModel
Class Method Details
.find_or_create ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/procon_bypass_man/web/models/setting.rb', line 11 def self.find_or_create(*) rows = db.execute("select * from #{table_name}") if rows.size.zero? db.execute("insert into #{table_name} (#{column_names.join(", ")}) values (?, ?)", ['', '']) return new(['', '']) else return new(rows.first) end end |