Skip to content

Instantly share code, notes, and snippets.

View radar's full-sized avatar

Ryan Bigg radar

View GitHub Profile
# current_account.time_blocks.recently_updated
# result -> lots of records
# current_account.appointments.recently_updated
# result -> NoMethodError Exception: undefined method `recently_updated' for #<Class:0x007fe6a7a13ef8>
class Appointment < ActiveRecord::Base
belongs_to :time_block
Animals.each do |letter, results|
10.times do
doc = Nokogiri::HTML(open("http://www.ocar.org/page.php?tut=realtor-affiliate-search-results&tid=802&pid=8&first_or_last_name=#{letter}&city=&office=&btc=&op=find_a_realtor&ftut=find-a-realtor&start=#{results_per_page}"))
realtors = {}
('a'..'z').each do |n|
realtors[n] = Realtor.create
end
doc.css('div.search_results_item').each do |number|
phone_number = /\(\d{3}\)\s\d{3}-\d{4}/.match("#{number.content}")
('a'..'z').each do |n|
@radar
radar / pages _microposts.html.erb
Created April 4, 2012 18:46 — forked from richardsondx/pages _microposts.html.erb
Endless page won't work with partial call instead of @render (which display my post with no css style)
<% for micropost in @microposts %>
<tr>
<td class="tdeux"><div class="head1"><%= image_tag("#{ micropost.to_guys ? "guys" : "girl" }-head.png") %></div></td>
<td valign="top"><p class="peopleposts"><%= link_to micropost.content, page_path(micropost) %></p></td>
<td class="td2"><div class="share1"><%= tweet_button(:via => "hmdy", :url => "http://localhost:3000/pages/#{micropost.id}", :text => "#{@micropost.content}", :lang => "en", :related => "helpmedateyou", :count => "none") %></div></td>
</tr>
<% end %>
time = Date.new(pyear, pmonth).to_time
monthname = Date::MONTHNAMES[time.month]
month = "%02d" % params[:month]
@gift_users = Cisco::TerminationCallDetail.initialize("1").find(:all, :conditions => ['DateTime >= ? AND DateTime <= ?', Date.new(pyear, pmonth).at_beginning_of_month, Date.new(pyear, pmonth).at_end_of_month])
Date.new(pyear, pmonth).at_beginning_of_month.upto(Date.new(pyear, pmonth).at_end_of_month) do |date|
#totalcounts << @gift_users.select{|u| u.datetime.to_s =~ /#{date.to_s}/ }.size
end
end
@radar
radar / mailer_observer.rb
Created April 2, 2012 17:06
how does this look
class MailerObserver < ActiveRecord::Observer
observer :device, :device_problem, :device_location
def after_create(device_problem)
DeviceMailer.problem_device(device_problem.device).deliver
end
def after_save(device_location)
# count active device_locations for location and check against par_levels
# send alert email if necessary
curl —header "X-Spree-Token: e115604bcaf72453e17ac548479e426a88c86adff56e87b1" http://127.0.0.1:3000/api/products.json
Started GET "/api/products.json" for 127.0.0.1 at 2012-03-27 14:54:58 +0100
Processing by Spree::Api::V1::ProductsController#index as JSON
Completed 500 Internal Server Error in 2ms
NoMethodError (undefined method `has_role?' for nil:NilClass):
/Users/briandquinn/Development/spree/api/app/controllers/spree/api/v1/products_controller.rb:45:in `scope'
/Users/briandquinn/Development/spree/api/app/controllers/spree/api/v1/products_controller.rb:6:in `index'
actionpack (3.2.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
@radar
radar / irb.sh
Created March 21, 2012 15:02 — forked from omarqureshi/irb.sh
1.8.7 :001 > autoload :MyLibrary, 'my_library'
=> nil
1.8.7 :002 > module FooModule
1.8.7 :003?> def foo
1.8.7 :004?> puts 'new foo'
1.8.7 :005?> end
1.8.7 :006?> end
=> nil
1.8.7 :007 > class MyLibrary
1.8.7 :008?> include FooModule
@radar
radar / routes.rb
Created March 20, 2012 15:29 — forked from anonymous/index.html.erb
Controller file, I want to access the complete method Im getting the following error undefined local variable or method complete_tasks_path
Mytasklistapp::Application.routes.draw do
resources :tasks do
member do
get :done
end
collection do
put :complete
end
end
@radar
radar / index.html.erb
Created March 16, 2012 17:22 — forked from jlebrech/index.html.erb
Form just displays blank
<%= form_for edit_multiple_game_flags_path(params[:game_id],@flags) do %>
<table class="accordion">
<thead>
<tr>
<th>Select</th>
<th>Player</th>
</tr>
</thead>
<tbody>
<% @flags.each do |f| %>
class DiscussionRepliesController < ApplicationController
before_filter :find_discussion
before_filter :find_discussionreply
def create
@discussionreply = @discussion.discussion_reply.new(params[:discussion_reply])
if @discussion_reply.save
flash[:notice] = "You replied to a discussion"
redirect_to [@discussion, @discussion_reply]
#redirect_to @discussion