Skip to content

Instantly share code, notes, and snippets.

View alan707's full-sized avatar

Alan Mond alan707

View GitHub Profile
@alan707
alan707 / forgot_password_error
Last active December 17, 2015 06:18
error devise forgot_password
ArgumentError (wrong number of arguments (2 for 1)):
app/mailers/user_mailer.rb:58:in `reset_password_instructions'
@alan707
alan707 / User.rb
Last active December 14, 2015 11:29
class User < ActiveRecord::Base
attr_accessible :email, :facebook_id, :firstname, :lastname, :username, :facebook_username, :photo_url
def to_param
username
end
def as_json(options={})
Started PUT "/audio_clips/25.json" for 127.0.0.1 at 2013-02-23 23:34:25 -0500
Processing by AudioClipsController#update as JSON
Parameters: {"play_count"=>"4", "id"=>"25"}
AudioClip Load (0.3ms) SELECT "audio_clips".* FROM "audio_clips" WHERE "audio_clips"."id" = ? LIMIT 1 [["id", "25"]]
(0.1ms) begin transaction
(0.1ms) commit transaction
(0.1ms) begin transaction
(0.0ms) commit transaction
Completed 200 OK in 91ms (Views: 3.4ms | ActiveRecord: 3.8ms)
#Put Command Sent:
curl -i -H "Accept: application/json" -X PUT -d "like_count=5" http://localhost:3000/audio_clips/25.json
#Response Received
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
X-UA-Compatible: IE=Edge
ETag: "7ae5757e1b786a3feb1a604a4991df94"
@alan707
alan707 / controller.rb
Created February 3, 2013 14:44
clips controller
def show
@audio_clip = AudioClip.find(params[:id])
@client = Foursquare2::Client.new(:client_id => 'client_id', :client_secret => 'client_secret')
@audio_clip.fsvenue = @client.search_venues(:ll => '36.142064,-86.816086')
respond_to do |format|
format.html # show.html.erb
format.json { render json: @audio_clip }
end
end
@alan707
alan707 / output from forsquare API
Created February 3, 2013 14:37
json output from foursquare
--- !ruby/hash:Hashie::Mash groups: - !ruby/hash:Hashie::Mash type: places name: Places items: - !ruby/hash:Hashie::Mash id: 4b2afcaaf964a5205bb324e3 name: Starbucks contact: !ruby/hash:Hashie::Mash phone: '6153210262' formattedPhone: (615) 321-0262 twitter: starbucks location: !ruby/hash:Hashie::Mash address: 3005 West End Ave crossStreet: 30th Ave lat: 36.143513 lng: -86.813939 distance: 251 postalCode: '37203' city: Nashville state: TN country: United States cc: US canonicalUrl: https://foursquare.com/v/starbucks/4b2afcaaf964a5205bb324e3 categories: - !ruby/hash:Hashie::Mash id: 4bf58dd8d48988d1e0931735 name: Coffee Shop pluralName: Coffee Shops shortName: Coffee Shop icon: https://foursquare.com/img/categories/food/coffeeshop.png parents: - Food primary: true verified: true restricted: true stats: !ruby/hash:Hashie::Mash checkinsCount: 8828 usersCount: 2370 tipCount: 44 likes: !ruby/hash:Hashie::Mash count: 0 groups: [] menu: !ruby/hash:Hashie::Mash type: foodAndBeverage url: https://foursquare.com/v/star
## Configuration
Geocoder.configure(
:timeout => 5,
:units => :km
)
@alan707
alan707 / terminal.sql
Created January 6, 2013 19:27
output of terminal
This is what I get in the terminal:
Started GET "/profiles/1" for 127.0.0.1 at 2013-01-06 14:24:07 -0500
Processing by ProfilesController#show as HTML
Parameters: {"id"=>"1"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", "1"]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
RentalAgreement Load (0.3ms) SELECT "rental_agreements".* FROM "rental_agreements" WHERE "rental_agreements"."owner_id" = 1
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
(0.2ms) SELECT COUNT(*) FROM "reviews" WHERE "reviews"."user_id" = 1
def show
@user=User.find(params[:id])
@user.set_view_profile(@user.id, false)
@rental_agreements = RentalAgreement.where(:owner_id => @user.id)
@tools = Tool.where(:user_id => @user.id)
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user }
@alan707
alan707 / gist:4349776
Created December 21, 2012 00:22
output with SQL failing to enter the correct values
Started POST "/rental_agreements" for 127.0.0.1 at 2012-12-20 19:19:29 -0500
Processing by RentalAgreementsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"yfiXJUvhXm/8XsmLwNLOYOIVHulcZdQ7dadhvhvAHfo=", "rental_agreement"=>{"term_start"=>"12-15-2012", "term_end"=>"12-19-2013", "agreed_price"=>"", "owner_id"=>"23", "tool_id"=>"1", "borrower_id"=>"23", "agreed_terms"=>"1"}, "commit"=>"Send Rental Proposal to Owner"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 23 LIMIT 1
(0.1ms) begin transaction
SQL (1.0ms) INSERT INTO "rental_agreements" ("agreed_price", "agreed_terms", "approved", "borrower_id", "created_at", "owner_id", "term_duration_hours", "term_end", "term_start", "tool_id", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["agreed_price", nil], ["agreed_terms", "1"], ["approved", nil], ["borrower_id", 23], ["created_at", Fri, 21 Dec 2012 00:19:29 UTC +00:00], ["owner_id", 23], ["term_duration_hours", nil], ["term_end", nil], ["term_