七度&光 2015-07-24 09:25 采纳率: 22.2%
浏览 13

方法不允许滑轨

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.

  • 写回答

2条回答 默认 最新

  • 三生石@ 2015-07-24 12:10
    关注

    I removed the below line in application.rb and the issue got resolved. config.assets.prefix="/chefUI"

    I don't understand what config.assets.prefix has to do with POST requests, but this resolved my issue.

    Would love to understand the reason though.

    评论

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)