Created
March 7, 2013 21:15
-
-
Save wingrunr21/5111857 to your computer and use it in GitHub Desktop.
her does not pass query parameters when doing relation lookups
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
2013-03-07 14:14:35] INFO WEBrick 1.3.1 | |
[2013-03-07 14:14:35] INFO ruby 1.9.3 (2013-01-15) [x86_64-darwin12.3.0] | |
[2013-03-07 14:14:35] INFO WEBrick::HTTPServer#start: pid=54326 port=3000 | |
her version: 0.4.1 | |
localhost - - [07/Mar/2013:14:14:35 MST] "GET /users/1?foobar=true HTTP/1.1" 200 10 | |
- -> /users/1?foobar=true | |
localhost - - [07/Mar/2013:14:14:35 MST] "GET /users/1/projects HTTP/1.1" 200 10 | |
- -> /users/1/projects | |
[2013-03-07 14:14:35] INFO going to shutdown ... | |
[2013-03-07 14:14:35] INFO WEBrick::HTTPServer#start done. |
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
require 'her' | |
require 'webrick' | |
class DummyServlet < WEBrick::HTTPServlet::AbstractServlet | |
def do_GET(req, res) | |
res.body = '{"id":"1"}' | |
res['Content-Type'] = "application/json" | |
end | |
end | |
server = WEBrick::HTTPServer.new(:Port => 3000) | |
server.mount("/", DummyServlet) | |
t = Thread.new { server.start } | |
trap(:INT) do | |
server.shutdown | |
t.join | |
exit | |
end | |
Her::API.setup :url => "http://localhost:3000" do |connection| | |
connection.use Faraday::Request::UrlEncoded | |
connection.use Her::Middleware::DefaultParseJSON | |
connection.use Faraday::Adapter::NetHttp | |
end | |
class Project | |
include Her::Model | |
end | |
class User | |
include Her::Model | |
has_many :projects | |
end | |
puts "\nher version: #{Her::VERSION}" | |
u = User.find(1, :foobar => true) | |
u.projects(:foobar => true) | |
server.shutdown | |
t.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment