Skip to content

Instantly share code, notes, and snippets.

View abloom's full-sized avatar

Andrew Bloom abloom

  • Turquoise Health
  • Chicago Il
View GitHub Profile
<% form_remote_for(@order, :builder => TaggedBuilder, :url => ship_admin_order_path(@order.applicant)) do |f| %>
<% fields_for ManualOrderInfo.new do |oi| %>
<label for="manual_order_info_note">Note:</label><%= oi.text_field :note %>
<% end %>
<%= submit_tag (@order.applicant.fulfilled? ? "Re-Ship" : "Ship") %>
<% end %>
def create
old_values = GeneralEdit.new(@board.attributes.slice(*GeneralEdit.new.attribute_names))
new_values = GeneralEdit.new(params[:general_edit])
new_values.attributes.each { |key, value| if value == "" then new_values[key] = nil end }
changed = new_values.attributes.diff(old_values.attributes)
session[:edit_result_id] = nil
if !changed.empty? then
@edit = GeneralEdit.new(changed)
@edit.board_id = params[:id]
def busy
result = EditResult.first
respond_to do |format|
format.js { result.to_json }
end
end
<script type="text/javascript">
new PeriodicalExecuter(function(pe) {
new Ajax.Request("/general/busy/<%= @edit.id %>", {
method: "get",
onSuccess: function(transport) {
//we must figure out what to put here
}
}
}, 1);
</script>
require 'hotcocoa'
require File.dirname(__FILE__)+'/mappings/status_item'
include HotCocoa
class Application
def start
application :name => "VPN Bar" do |app|
app.delegate = self
class Player < ActiveRecord::Base
belongs_to :team
end
class Team < ActiveRecord::Base
has_many :leagues
has_many :players
end
class League < ActiveRecord::Base
module ApplicationHelper
def content_block(name, &block)
override = yield(name)
return override unless override.blank?
return capture(block)
end
end
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
rescue_from ActiveRecord::RecordNotFound do |e|
logger.error e.message
render_404
end
protected
ActionController::Routing::Routes.draw do |map|
map.resources :fans
map.resources :league_players
map.logout '/logout', :controller => 'sessions', :action => 'destroy'
map.login '/login', :controller => 'sessions', :action => 'new'
map.check '/check', :controller => 'sessions', :action => 'create'
class User
class Authorization
end
end
u = User.new
a = User::Authorization.new