0
裝載模板Ruby on Rails的3.2跳過從控制器
我有我的觀點一個AJAX腳本運行我在我的控制器創建方法。所有工作都很好,但我在日誌中注意到它正在尋找一個模板。我通常會重定向或讓它做某事,但這次我不希望它做任何事情。
如何跳過或打破模板查找?
我的觀點:
$(document).ready(function() {
$.ajax({
type: 'GET',
dataType: 'script',
url: '/track' + '<%= url_for(action: "create") %>'
});
});
我的控制器:
def create
@reseller_name = Reseller.find("#{current_user.reseller_id}").company_name
@track = Track.create(name: "#{current_user.name}", user_id: "#{current_user.id}", reseller_id: "#{current_user.reseller_id}", reseller_name: "#{@reseller_name}")
#This is where I would normally have a render or redirect, I just want it to stop, and not look for a template.
end
我的日誌:
(26.8ms) COMMIT
Completed 500 Internal Server Error in 85ms
ActionView::MissingTemplate (Missing template tracks/create, application/create with {:locale=>[:en], :formats=>[:js, "application/ecmascript", "application/x-ecmasc
ript", :html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip, :
xls], :handlers=>[:erb, :builder, :coffee]}. Searched in:
* "/opt/RoR/reseller_connect/app/views"
):
大,你可以給你的來源嗎? – DDDD
http://guides.rubyonrails.org/layouts_and_rendering.html#using-render – tirdadc
+1對於資源。 – DDDD