Skip to content

Instantly share code, notes, and snippets.

# Equipment model
class Equipment < ActiveRecord::Base
def price
read_attribute(:price).to_i
end
end
# Form _form.erb
<%= f.fields_for :equipment do |builder| -%>
<%= render "equipment_fields", :f => builder %>
@sher
sher / gist:921693
Created April 15, 2011 13:34 — forked from Znow/gist:921691
- @employees.each do |employee|
%span{:style=>"float:left;margin-right:20px;"}= image_tag employee.image
%div{:style=>"float:left;margin-top:30px;"}
= employee.name
,
= employee.title
%br/
%br/
= mail_to employee.email
equire File.join(File.dirname(__FILE__), 'boot')
RAILS_GEM_VERSION = '2.3.9' unless defined? RAILS_GEM_VERSION
Rails::Initializer.run do |config|
config.time_zone = 'UTC'
config.gem 'declarative_authorization', :source => 'http://gemcutter.org'
config.gem 'searchlogic'
@sher
sher / base_model.rb
Created March 25, 2011 09:25
Tableless models in Rails 3
class BaseModel < ActiveRecord::Base
def self.columns
@columns ||= [];
end
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
end
def save(validate = true)