This file contains hidden or 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
# every rails plugin should have an init.rb in the top level | |
PluginManager.register(MyPluginClass, :tab_generator) |
This file contains hidden or 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 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 file contains hidden or 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
#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 %> |
This file contains hidden or 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 LinkBar | |
include Singleton | |
def initialize | |
@bars = Hash.new | |
@bars.default = [] | |
end | |
def register(linkbar_name, class_name, callback_method) | |
@bars[linkbar_name] << {:class => class_name, :method => callback_method} |
This file contains hidden or 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 LinkBar | |
def initialize | |
@bars = Hash.new | |
end | |
def register(linkbar_name, links) | |
@bars[linkbar_name] ||= [] | |
@bars[linkbar_name].concat links | |
end | |
This file contains hidden or 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/link_bar.rb | |
require 'singleton' | |
class LinkBar | |
include Singleton | |
class << self | |
def register(callback) | |
instance.register(callback) | |
end |
This file contains hidden or 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 BoardController < ActionController::Base | |
before_filter :build_nav_bar_links | |
def index | |
... | |
end | |
private | |
def build_nav_bar_links | |
@nav_bar_links = nav_bar_links |
This file contains hidden or 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
#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 |
This file contains hidden or 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
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> |
This file contains hidden or 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
#!/usr/bin/ruby | |
cmd = "#{File.dirname(__FILE__)}/tmp.rb" | |
out = IO.popen(cmd) do |child| | |
until child.eof? | |
puts child.gets | |
end | |
end |