0
我有一個動作common/location
Ruby on Rails的包括一個javascript從動作
#encoding: utf-8
class CommonController < ApplicationController
def location
@locations=Location.select(['`key`','name','parent'])
render json: @locations
end
end
我想包括這個js通過:
=javascript_include_tag "common/location"
但這這麼想的工作!
所以我想知道如何從一個包括js。
是不是json,而不是javascript?即使你可以像這樣包括它,它會有什麼好處? –
javascript_include_tag用於包含JavaScript文件,而不是在您的視圖中呈現json代碼。 – calas
= javascript_include_tag url_for(action:'location',controller:'common') – HXH