Skip to content

Instantly share code, notes, and snippets.

View gist:5022611
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)
View JSON data sent and returned
#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"
View controller.rb
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 Feb 3, 2013
json output from foursquare
View output from forsquare API
--- !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
View geocoder.rb
## Configuration
Geocoder.configure(
:timeout => 5,
:units => :km
)
@alan707
alan707 / terminal.sql
Created Jan 6, 2013
output of terminal
View terminal.sql
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
View profiles_controller.rb
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 Dec 21, 2012
output with SQL failing to enter the correct values
View gist:4349776
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_
View gist:4349767
Started POST "/rental_agreements" for 127.0.0.1 at 2012-12-20 19:16:33 -0500
Processing by RentalAgreementsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"yfiXJUvhXm/8XsmLwNLOYOIVHulcZdQ7dadhvhvAHfo=", "rental_agreement"=>{"term_start"=>"12-10-2012", "term_end"=>"12-02-2013", "agreed_price"=>"2", "owner_id"=>"23", "tool_id"=>"1", "borrower_id"=>"23", "agreed_terms"=>"0"}, "commit"=>"Send Rental Proposal to Owner"}
View controller.rb
def create
@rental_agreement = RentalAgreement.new(params[:rental_agreement])
# UserMailer.rental_email(current_user, @rental_agreement.tool_id).deliver
respond_to do |format|
if @rental_agreement.save
format.html { redirect_to rental_agreement_path(id: @rental_agreement.id), notice: 'Rental agreement was successfully created.' }
format.json { render json: @rental_agreement, status: :created, location: @rental_agreement }
else
You can’t perform that action at this time.