我面临一个非常奇怪的路由错误,我似乎无法在 Rails 3.2.11 中解决
错误是:AbstractController::ActionNotFound(找不到 SubmissionsController 的操作“bulk_submissions_url”)
我有一条看起来像这样的路线:
match 'submissions/bulk_submissions_url' => 'submissions#bulk_submissions_url', :as => 'bulk_submissions_url', :via => :post
如下所示的 SubmissionsController:
class SubmissionsController < ApplicationController
...
def bulk_submissions_url
if signed_in?
#get the cert that the user has if they are returning to tutorial
if current_user.enrollments and current_user.enrollments.length > 0
@enrollment = current_user.enrollments.last
else
#handle this
end
@submission = Submission.create!(url: params[:url], description: "Please edit this description", work_type: "other", date_completed: DateTime.now.to_date)
if @submission.save
@enrollment.submissions << @submission
render :json => { success: true, submission_id: @submission.id }
else
render :json => { success: false }
end
end
end
我正在使用 jQuery 发出请求:
//save the submission
$.ajax({
type: 'POST',
url: '<%= bulk_submissions_url_path %>',
data: {url : $("#tutorial_add_work_url_input").val()},
dataType: 'json'
});
有什么我想念的吗?
提前致谢!