Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separating into API and Client #24

Open
marissamarym opened this issue May 22, 2014 · 2 comments
Open

Separating into API and Client #24

marissamarym opened this issue May 22, 2014 · 2 comments

Comments

@marissamarym
Copy link

Not really an issue but I've just started learning rails and I've been trying to separate this project into a client that doesn't use Sinatra and a json API for a few days now, and I'm getting internal server errors when I try to access /save-post by doing this:

uri = URI('http://hidden-caverns-8480.herokuapp.com/admin/save-post.json')
req = Net::HTTP::Post.new(uri.path)
req.basic_auth username, password
data = {
"method" => "put",
"post" => { "title" => "mytitleeee", "name" => "gjh", "content" => "hiiii" },
"commit" => "Save",
"ajax" => "true"
}.to_json
req.content_type = 'application/json'
req.body = data
http = Net::HTTP.new(uri.host, uri.port)
@myResponse = http.start {|http| http.request(req) }

Any advice? Thanks!

@alagu
Copy link
Owner

alagu commented May 23, 2014

Do you own that heroku app? Can you check the logs?

@marissamarym
Copy link
Author

Yep, I own it! Here are the logs. It looks like its going into the update_post method because it can't properly read the params:

Marissa-Montgomerys-MacBook-Pro-2:RecsyWebsiteDeployAPI marissamontgomery$ heroku logs
2014-05-23T23:43:17.387333+00:00 app[web.1]: [2014-05-23 23:43:17] INFO ruby 1.9.3 (2014-05-14) [x86_64-linux]
2014-05-23T23:43:17.387289+00:00 app[web.1]: [2014-05-23 23:43:17] INFO WEBrick 1.3.1
2014-05-23T23:43:17.387760+00:00 app[web.1]: [2014-05-23 23:43:17] INFO WEBrick::HTTPServer#start: pid=2 port=4528
2014-05-23T23:43:17.737345+00:00 heroku[web.1]: State changed from starting to up
2014-05-23T23:43:15.574371+00:00 heroku[web.1]: Starting process with command bundle exec rackup config.ru -p 4528
2014-05-23T23:43:16.477586+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2014-05-23T23:43:27.063406+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
2014-05-23T23:43:27.063406+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2014-05-23T23:43:29.071028+00:00 heroku[web.1]: Process exited with status 137
2014-05-23T23:43:56.003712+00:00 heroku[router]: at=info method=POST path=/admin/save-post host=hidden-caverns-8480.herokuapp.com request_id=c3742128-9f8b-4ac7-be77-e78b1f18493e fwd="75.149.100.254" dyno=web.1 connect=2ms service=2650ms status=500 bytes=326
2014-05-23T23:43:55.997589+00:00 app[web.1]: /app/lib/pagoda/app.rb:83:in update_post' 2014-05-23T23:43:55.997621+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1293:incall'
2014-05-23T23:43:55.997591+00:00 app[web.1]: /app/lib/pagoda/app.rb:172:in block in <class:App>' 2014-05-23T23:43:55.997584+00:00 app[web.1]: NoMethodError - undefined method[]' for nil:NilClass:
2014-05-23T23:43:55.997623+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1293:in block in compile!' 2014-05-23T23:43:55.997625+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:860:in[]'
2014-05-23T23:43:55.997626+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:860:in block (3 levels) in route!' 2014-05-23T23:43:55.997628+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:876:inroute_eval'
2014-05-23T23:43:55.997634+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:895:in process_route' 2014-05-23T23:43:55.997636+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:859:inblock in route!'
2014-05-23T23:43:55.997633+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:895:in catch' 2014-05-23T23:43:55.997647+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:794:inblock in call!'
2014-05-23T23:43:55.997630+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:860:in block (2 levels) in route!' 2014-05-23T23:43:55.997644+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:ininvoke'
2014-05-23T23:43:55.997631+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:897:in block in process_route' 2014-05-23T23:43:55.997645+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:960:indispatch!'
2014-05-23T23:43:55.997648+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:in block in invoke' 2014-05-23T23:43:55.997649+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:incatch'
2014-05-23T23:43:55.997637+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:858:in each' 2014-05-23T23:43:55.997651+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:ininvoke'
2014-05-23T23:43:55.997639+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinat
ra-1.3.6/lib/sinatra/base.rb:858:in route!' 2014-05-23T23:43:55.997640+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:963:inblock in dispatch!'
2014-05-23T23:43:55.997652+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:794:in call!' 2014-05-23T23:43:55.997642+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:inblock in invoke'
2014-05-23T23:43:55.997653+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:780:in call' 2014-05-23T23:43:55.997643+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:incatch'
2014-05-23T23:43:55.997655+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/xss_header.rb:18:in call' 2014-05-23T23:43:55.997706+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:incall'
2014-05-23T23:43:55.997720+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:138:in call' 2014-05-23T23:43:55.997709+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/nulllogger.rb:9:incall'
2014-05-23T23:43:55.997710+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/head.rb:11:in call' 2014-05-23T23:43:55.997704+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:incall'
2014-05-23T23:43:55.997728+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/showexceptions.rb:24:in call' 2014-05-23T23:43:55.997719+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:124:incall'
2014-05-23T23:43:55.997738+00:00 app[web.1]: /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in block in start_thread' 2014-05-23T23:43:55.997722+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/urlmap.rb:65:inblock in call'
2014-05-23T23:43:55.997723+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in each' 2014-05-23T23:43:55.997656+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/path_traversal.rb:16:incall'
2014-05-23T23:43:55.997725+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in call' 2014-05-23T23:43:55.997657+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/json_csrf.rb:18:incall'
2014-05-23T23:43:55.997726+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/auth/basic.rb:25:in call' 2014-05-23T23:43:55.997707+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/frame_options.rb:31:incall'
2014-05-23T23:43:55.997729+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in service' 2014-05-23T23:43:55.997730+00:00 app[web.1]: /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:inservice'
2014-05-23T23:43:55.997732+00:00 app[web.1]: /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' 2014-05-23T23:44:42.171040+00:00 heroku[router]: at=info method=POST path=/admin/save-post host=hidden-caverns-8480.herokuapp.com request_id=1d5c3597-4e3a-4282-9156-67df3909a708 fwd="75.149.100.254" dyno=web.1 connect=0ms service=6ms status=500 bytes=326 2014-05-23T23:44:42.158174+00:00 app[web.1]: /app/lib/pagoda/app.rb:172:inblock in class:App'
2014-05-23T23:44:42.158176+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1293:in call' 2014-05-23T23:44:42.158165+00:00 app[web.1]: NoMethodError - undefined method[]' for nil:NilClass:
2014-05-23T23:44:42.158172+00:00 app[web.1]: /app/lib/pagoda/app.rb:83:in update_post' 2014-05-23T23:44:42.158178+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1293:inblock in compile!'
2014-05-23T23:44:42.158180+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:860:in []' 2014-05-23T23:44:42.158181+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:860:inblock (3 levels) in route!'
2014-05-23T23:44:42.158183+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:876:in route_eval' 2014-05-23T23:44:42.158184+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:860:inblock (2 levels) in route!'
2014-05-23T23:44:42.158186+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:897:in block in process_route' 2014-05-23T23:44:42.158187+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:895:incatch'
2014-05-23T23:44:42.158189+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:895:in process_route' 2014-05-23T23:44:42.158190+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:859:inblock in route!'
2014-05-23T23:44:42.158192+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:858:in each' 2014-05-23T23:44:42.158213+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:858:inroute!'
2014-05-23T23:44:42.158215+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:963:in block in dispatch!' 2014-05-23T23:44:42.158217+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:inblock in invoke'
2014-05-23T23:44:42.158218+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:in catch' 2014-05-23T23:44:42.158219+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:ininvoke'
2014-05-23T23:44:42.158221+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:960:in dispatch!' 2014-05-23T23:44:42.158222+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:794:inblock in call!'
2014-05-23T23:44:42.158223+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:in block in invoke' 2014-05-23T23:44:42.158225+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:incatch'
2014-05-23T23:44:42.158226+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:in invoke' 2014-05-23T23:44:42.158228+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:794:incall!'
2014-05-23T23:44:42.158237+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:780:in call' 2014-05-23T23:44:42.158238+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/xss_header.rb:18:incall'
2014-05-23T23:44:42.158240+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/path_traversal.rb:16:in call' 2014-05-23T23:44:42.158245+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:incall'
2014-05-23T23:44:42.158246+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/frame_options.rb:31:in call' 2014-05-23T23:44:42.158241+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/json_csrf.rb:18:incall'
2014-05-23T23:44:42.158243+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in call' 2014-05-23T23:44:42.158247+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/nulllogger.rb:9:incall'
2014-05-23T23:44:42.158250+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/head.rb:11:in call' 2014-05-23T23:44:42.158251+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:124:incall'
2014-05-23T23:44:42.158252+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:138:in call' 2014-05-23T23:44:42.158264+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/urlmap.rb:65:inblock in call'
2014-05-23T23:44:42.158265+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in each' 2014-05-23T23:44:42.158267+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/urlmap.rb:50:incall'
2014-05-23T23:44:42.158268+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/auth/basic.rb:25:in call' 2014-05-23T23:44:42.158270+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/showexceptions.rb:24:incall'
2014-05-23T23:44:42.158271+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in service' 2014-05-23T23:44:42.158272+00:00 app[web.1]: /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:inservice'
2014-05-23T23:44:42.158274+00:00 app[web.1]: /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' 2014-05-23T23:44:42.158275+00:00 app[web.1]: /app/vendor/ruby-1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants