{"id":2700,"date":"2022-08-30T15:27:03","date_gmt":"2022-08-30T15:27:03","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/02\/06\/sinatra-modular-app-not-recognizing-routes-on-appfog-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:27:03","modified_gmt":"2022-08-30T15:27:03","slug":"sinatra-modular-app-not-recognizing-routes-on-appfog-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/sinatra-modular-app-not-recognizing-routes-on-appfog-collection-of-common-programming-errors\/","title":{"rendered":"Sinatra Modular app not recognizing routes on AppFog-Collection of common programming errors"},"content":{"rendered":"<p>I have started writing my Sinatra apps using a modular style, suggested in this stackoverflow answer, and have successfully deployed it on Heroku, but when trying to deploy to AppFog (identical code except for datamapper mysql\/postgres gems) I get &#8220;Not Found&#8221; errors for every route I have defined.<\/p>\n<pre><code>== Sinatra\/1.3.3 has taken the stage on 47195 for production with backup from Thin\nmyIP, 127.0.0.1 - - [08\/Dec\/2012 21:28:53] \"GET \/ HTTP\/1.0\" 404 18 0.0030\nmyIP, 127.0.0.1 - - [08\/Dec\/2012 21:28:54] \"GET \/any_route HTTP\/1.0\" 404 18 0.0010\nmyIP, 127.0.0.1 - - [08\/Dec\/2012 21:28:58] \"GET \/about HTTP\/1.0\" 404 18 0.0008\n<\/code><\/pre>\n<p>My view and public paths from settings:<\/p>\n<pre><code>settings.views = \".\/views\"\nroot = \".\"\nsettings.sin_auth_view_path =  \"\/mnt\/var\/vcap.local\/dea\/apps\/myapp-0-d1d1d1dc0e543b1759afda27b\/app\/views\/\"\npublic_folder = \".\/public\"\n<\/code><\/pre>\n<p>An example of defined route:<\/p>\n<pre><code>class MyApp &lt; Sinatra::Application\n  get '\/' do\n    @title = \"Site Index Page\"\n\n    haml :index\n  end\nend\n<\/code><\/pre>\n<p>Config.ru<\/p>\n<pre><code>require ::File.join( ::File.dirname(__FILE__), 'app')\n\nrun MyApp.new\n<\/code><\/pre>\n<p>Structure is basically identical to that linked to above.<\/p>\n<p>There are no application errors, just the &#8220;Not Found&#8221; message and corresponding 404 &#8220;GET&#8221; entries in the logs. The PUBLIC folder is working as it should &#8211; I can access all static files off the site url (ie. <code>site.com\/img\/anypic.jpg<\/code>). And, as I mentioned, the exact same app runs flawlessly on Heroku.<\/p>\n<p>I am using bundle package, so a custom gem can be used, and had no problems until switching to the modular structure.<\/p>\n<p>Installed on AppFog Ruby 1.9.3 Runtime.<\/p>\n<p>Thoughts&#8230;.<\/p>\n<ol>\n<li>\n<p>Thanks to a user on the AppFog Google User Group, the solution was to deploy as a <strong>Rack<\/strong> application instead of a <strong>Sinatra<\/strong> application.<\/p>\n<p>Note: Also make sure to use the <code>--runtime ruby193<\/code> command line option, if you are using <code>require_relative<\/code> \ud83d\ude42<\/p>\n<\/li>\n<li>\n<p>I would check to see if you might be having a problem with the &#8220;settings.sin_auth_view_path&#8221; entry as it&#8217;s an absolute path (whereas the other two are relative). Heroku does not have the normal filesystem layout that you&#8217;re used to seeing on a development box once you ascend outside your app&#8217;s source.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-02-06 04:21:20. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I have started writing my Sinatra apps using a modular style, suggested in this stackoverflow answer, and have successfully deployed it on Heroku, but when trying to deploy to AppFog (identical code except for datamapper mysql\/postgres gems) I get &#8220;Not Found&#8221; errors for every route I have defined. == Sinatra\/1.3.3 has taken the stage on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2700","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2700"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2700\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}