Ich habe eine Route funktioniert gut in meiner Entwicklungsumgebung, aber aus irgendeinem Grund funktioniert es nicht in der Produktion und ich kann nicht herausfinden, warum.Schienen Routen unterschiedlich in Entwicklung und Produktion
Wenn ich in meiner Entwicklungsumgebung zu http://localhost:3000/api/v1/register_panelist?api_key=ff4a6fa1c975693bedc2122e6943946b
gehe, funktioniert es großartig.
Allerdings, wenn ich gehe http://example.com/api/v1/register_panelist?api_key=ff4a6fa1c975693bedc2122e6943946b
es nicht auflösen, und landet auf eine "Seite nicht gefunden", die der Fang ist alle Route am unteren Rand meiner Routen-Datei.
In meiner routes.rb
Datei Ich habe diese:
constraints(ApiConstraint) do
namespace :api, defaults: {format: 'json'} do
namespace :v1, defaults: {format: 'json'} do
match "register_panelist", to: "appusers#register_panelist", via: 'get'
match "get_surveys", to: "appusers#get_surveys", via: 'get'
end
end
match "api/v1/*path", to: "api/v1/misc#api_not_found_404", via: :all, format: 'json'
end
...
#at the very bottom
match "*path", to: "static_pages#not_found_404", via: :all, format: false #, :constraints => {:format => [:html, :png]}
In meiner Entwicklungsumgebung um es richtig zu lösen scheint. Aber in der Produktion scheint es bis zum Ende der routes.rb
Datei zu fallen.
Irgendwelche Ideen warum?
EDIT: Hinzufügen von Logs:
Produktion:
production.log — I, [2017-02-12T11:55:31.455331 #27545] INFO -- : Started GET "/api/v1/register_panelist.json?api_key=ff4a6fa1c975693bedc2122e6943946b&country_id=9&birthday_year=1989&birthday_month=2&birthday_day=16&gender=42198&hispanic=42200&zip=10022&state=45700ðnicity=42215&standard_relationship=42232&standard_education=42243&standard_hhi_us=43511" for 75.100.38.224 at 2017-02-12 11:55:31 +0000
production.log — I, [2017-02-12T11:55:31.606946 #27545] INFO -- : Prod? true
production.log — I, [2017-02-12T11:55:31.607886 #27545] INFO -- : subdomain:
production.log — I, [2017-02-12T11:55:31.607948 #27545] INFO -- : protocol: https://
production.log — I, [2017-02-12T11:55:31.608020 #27545] INFO -- : Prod? true
production.log — I, [2017-02-12T11:55:31.608052 #27545] INFO -- : subdomain:
production.log — I, [2017-02-12T11:55:31.608086 #27545] INFO -- : protocol: https://
production.log — I, [2017-02-12T11:55:31.617812 #27545] INFO -- : Processing by StaticPagesController#not_found_404 as HTML
production.log — I, [2017-02-12T11:55:31.617925 #27545] INFO -- : Parameters: {"api_key"=>"ff4a6fa1c975693bedc2122e6943946b", "country_id"=>"9", "birthday_year"=>"1989", "birthday_month"=>"2", "birthday_day"=>"16", "gender"=>"42198", "hispanic"=>"42200", "zip"=>"10022", "state"=>"45700", "ethnicity"=>"42215", "standard_relationship"=>"42232", "standard_education"=>"42243", "standard_hhi_us"=>"43511", "path"=>"api/v1/register_panelist.json"}
production.log — I, [2017-02-12T11:55:31.636463 #27545] INFO -- : Rendered text template (0.2ms)
production.log — I, [2017-02-12T11:55:31.636883 #27545] INFO -- : Completed 404 Not Found in 19ms (Views: 11.4ms | ActiveRecord: 0.0ms)
Entwicklung:
Started GET "/api/v1/register_panelist?api_key=ff4a6fa1c975693bedc2122e6943946b&country_id=9&birthday_year=1989&birthday_month=2&birthday_day=16&gender=42198&hispanic=42200&zip=53593&state=45700ðnicity=42215&standard_relationship=42232&standard_education=42243&standard_hhi_us=43511" for ::1 at 2017-02-12 05:56:46 -0600
Prod? false
subdomain:
protocol: http://
Processing by Api::V1::AppusersController#register_panelist as JSON
Parameters: {"api_key"=>"ff4a6fa1c975693bedc2122e6943946b", "country_id"=>"9", "birthday_year"=>"1989", "birthday_month"=>"2", "birthday_day"=>"16", "gender"=>"42198", "hispanic"=>"42200", "zip"=>"53593", "state"=>"45700", "ethnicity"=>"42215", "standard_relationship"=>"42232", "standard_education"=>"42243", "standard_hhi_us"=>"43511"}
User Load (18.7ms) SELECT "users".* FROM "users" WHERE "users"."api_key" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["api_key", "ff4a6fa1c975693bedc2122e6943946b"]]
rake routes
Ausgang von der Entwicklung:
api_v1_register_panelist GET /api/v1/register_panelist(.:format) api/v1/appusers#register_panelist {:format=>"json"}
api_v1_get_surveys GET /api/v1/get_surveys(.:format) api/v1/appusers#get_surveys {:format=>"json"}
und Produktionsserver:
api_v1_register_panelist GET /api/v1/register_panelist(.:format) api/v1/appusers#register_panelist {:format=>"json"}
api_v1_get_surveys GET /api/v1/get_surveys(.:format) api/v1/appusers#get_surveys {:format=>"json"}
können Sie Anfrageprotokolle für dev & prod teilen? – Abhishek