I am making an ajax post call to a controller. My Ajax call is:
$.ajax({
type:'POST',
url:'/chefUI/configure/save_roles',
data:{ app_name: appname, role_list: role_list},...});
My Routes file is:
scope "/chefUI" do
post '/configure/save_roles', to: 'admin#update_app_roles'
end
And my controller has:
def update_app_roles
begin
application_name = params["app_name"]
puts application_name
role_name_list = params["role_list"]
puts role_name_list
if application_name and !role_name_list.empty?
...
And I am getting a 405 Method Not Allowed response. I'm not sure what are the reasons this might happen. Could someone help me figure out what I'm missing here? I don't why my post request is not even reaching my controller.
Update:
Log file
Started GET "/chefUI/configure/app_roles?app_name=MFRH" for 127.0.0.1 at 2015-07-24 15:08:51 +0530 Processing by AdminController#app_roles as */* Parameters: {"app_name"=>"MFRH"} [1m[35mUser Load (1.0ms)[0m SELECT "users".* FROM "users" WHERE "users"."username" = $1 LIMIT 1 [["username", "an9v0s7"]] [1m[36mApplication Load (2.0ms)[0m [1mSELECT "applications".* FROM "applications" WHERE (lower(app_name) = 'mfrh') ORDER BY "applications"."id" ASC LIMIT 1[0m [1m[35mRole Load (1.0ms)[0m SELECT "roles".* FROM "roles" INNER JOIN "application_roles" ON "roles"."id" = "application_roles"."role_id" WHERE "application_roles"."application_id" = $1 ORDER BY roles.name ASC [["application_id", 1]] Completed 200 OK in 217ms (Views: 0.0ms | ActiveRecord: 5.0ms)
Started POST "/chefUI/configure/save_roles" for 127.0.0.1 at 2015-07-24 15:08:57 +0530
Another Update:
I just found out that I'm getting that response for all my post requests. They were all working before, I created a bunch on new models and suddenly none of them are working.