This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BootStrapFormBuilder < ActionView::Helpers::FormBuilder | |
# non-relevant code removed.... | |
def text_field(*args, &block) | |
input_wrapper(args.first) { | |
super(*args, &block) | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for(@item, :builder => BootStrapFormBuilder) do |f| %> | |
<fieldset> | |
<legend><%= content_for :page_heading %></legend> | |
<%= f.text_field :pn %> | |
<%= f.text_field :desc %> | |
<%= f.text_area :memo, :rows => 3 %> | |
<%= f.select :vendor_id, Company.all(:order => [:name]).collect {|company| [company.name, company.id]}, {:include_blank => true}, {:class => 'span4'} %> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
users.fname, | |
users.lname, | |
TIMEZONE('UTC', users.created_at) AT TIME ZONE 'CST6CDT' | |
FROM | |
users; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = DateTime.parse("2011/01/01T00:00") + (Time.now.getlocal.utc_offset * -1).seconds | |
# Sat, 01 Jan 2011 06:00:00 +0000 | |
t.to_time.localtime | |
# 2011-01-01 00:00:00 -0600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Time.zone | |
# (GMT-06:00) Central Time (US & Canada) | |
DateTime.parse("2011/01/01T00:00").utc? | |
# true | |
DateTime.parse("2011/01/01T00:00").to_time.getlocal | |
# 2010-12-31 18:00:00 -0600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/core_ext/date.rb | |
require 'date' | |
class Date | |
class << self | |
alias :original_parse :_parse | |
def _parse(input, comp=true) | |
# mm-dd-yyyy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ItemsController < ApplicationController | |
# unrelated code.... | |
def create | |
@item = Item.new(params[:item]) | |
@item.invented_at = DateTime.parse(params[:item][:invented_at]) | |
if @item.save | |
redirect_to @item, :notice =>"The Item successfully created" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/items_controller.rb | |
class ItemsController < ApplicationController | |
# unrelated code.... | |
def create | |
@item = Item.new(params[:item]) | |
@item.invented_at = Time.strptime(params[:item][:invented_at], "%m/%d/%Y") | |
if @item.save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User. | |
select("users.id, users.full_name, string_agg(roles.name, ', ') as roles_col"). | |
joins(:memberships => :role). | |
group('users.id'). | |
each_with_object([[:id, :full_name, :roles]]){ |u,a| | |
a << [u.id, u.full_name, u.roles_col.split(',').map(&:strip) ] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
development: | |
adapter: postgresql | |
encoding: unicode | |
database: <%= File.basename(Rails.root) %>_development | |
pool: 5 | |
username: <%= ENV['USER'] %> | |
password: | |
test: | |
adapter: postgresql |