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
# every rails plugin should have an init.rb in the top level
PluginManager.register(MyPluginClass, :tab_generator)
class Controller < ActionController::Base
def update_all
keys = params.keys.find_all{ |k| k =~ /obj_\d+/ }
keys.each do |key
id = key.split("_").last
obj = Object.find(id)
obj.update_attributes(params[key])
end
end
end
#This is the form tag I normally have to do
<% #form_for game_player,:url => game_player_path(params[:slug], game_player) do |f| %>
#This is what I was trying
# This form submits to http://localhost:3000/game_players/update_all, I need the team slug in front
<% form_tag (:controller => "game_players", :action => "update_all") do %>
<% for game_player in @game_players %>
<% fields_for "game_player_#{game_player.id}" do |f| %>
<%= f.error_messages %>
class LinkBar
def initialize
@bars = Hash.new
end
def register(linkbar_name, links)
@bars[linkbar_name] ||= []
@bars[linkbar_name].concat links
end
# lib/link_bar.rb
require 'singleton'
class LinkBar
include Singleton
class << self
def register(callback)
instance.register(callback)
end
class BoardController < ActionController::Base
before_filter :build_nav_bar_links
def index
...
end
private
def build_nav_bar_links
@nav_bar_links = nav_bar_links
#include <stdlib.h>
#include <string.h>
#include <Nixie.h>
#include <MultiDAC.h>
#include "messaging.h"
// message types
#define DEMO_ID 1
#define MESSAGE_ID 2
#define CLEAR_ID 3
module OverrideHelper
# Call this method to setup a default content block by name. This content will be rendered into the page
# unless a content_block with the same name also exists somewhere else in the rendered response.
#
# === Examples
# Using a block for complex, or lengthy content
# <% content_default(:navigation) do %>
# <ul>
# <li><%= link "Home" %></li>
# <li><%= link "Product Info", "product-info" %></li>
#!/usr/bin/ruby
cmd = "#{File.dirname(__FILE__)}/tmp.rb"
out = IO.popen(cmd) do |child|
until child.eof?
puts child.gets
end
end