Skip to content

Instantly share code, notes, and snippets.

<h1>Promotional Merchandise Request</h1>
<h2>Available Items</h2>
<% form_for @order do |order_form| %>
<table>
<% order_form.fields_for :line_items do |line_item_form| %>
<% product = line_item_form.object.product %>
<%= line_item_form.hidden_field :product_id %>
<tr>
<td><%= image_tag product.image.url %></td>
<td><%= product.name %></td>
def content_navigation
content_for :content_navigation do
render :partial => 'navigation'
end
end
Here is an example of how I use it in my a view (new.html.erb):
<% content_navigation %>
<%= render :partial => 'form' %>
==========
This is my application helper:
module ApplicationHelper
@ryanhanks
ryanhanks / Gemfile.lock
Created March 1, 2011 04:28
Gemfile.lock
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.4)
actionpack (= 3.0.4)
mail (~> 2.2.15)
actionpack (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
def status
return "pending" if effective_date > Date.today
if cancellation_date
cancellation_date <= Date.today ? "cancelled" : "pending_cancellation"
else
if expiration_date <= Date.today
renew ? "renewed" : "expired"
else
"in_force"
end
# routes.rb
resources :fidelity_bonds do
resources :edits
member do
get :edit_principal
end
end
# app/views/fidelity_bonds/edit_principal.html.haml
= simple_form_for @fidelity_bond, :url => fidelity_bond_edits_path(@fidelity_bond) do |f|
Mbc::Application.routes.draw do
resources :fidelity_bonds do
resources :edits
member do
get :edit_principal
end
end
end
class FidelityBondPrincipalAddressUpdatesController < CommandsController
filter_resource_access :additional_member => [ :execute ]
before_filter :set_updated_by
def after_execute_path
command.receiver
end
def after_execute_flash_message
class Feed
def page
@page ||= get_url
end
def posts
@posts ||= do
post_nodes.map do |post_node|
build_post(post_node)
end
@ryanhanks
ryanhanks / gist:2694426
Created May 14, 2012 14:55
Benchmarking
FactoryMonitor.benchmarks = []
FactoryMonitor.stack = []
def run_with_monitor
self.class.stack.push self.class.benchmarks
self.class.benchmarks = child_results = []
results = Benchmark.get
self.class.benchmarks = self.class.stack.pop
self.class.benchmarks << [factory_name, results, child_results]
end