Javascript Rails 4:是否可以将Ajax.get请求发送到同一个当前页面控制器?
假设我的js.erb文件在根页面(application.html.erb)上发出ajax请求。我的ajax.get能否从应用程序索引中提取包含当前用户的变量Javascript Rails 4:是否可以将Ajax.get请求发送到同一个当前页面控制器?,javascript,jquery,ruby-on-rails,ajax,ruby-on-rails-4,Javascript,Jquery,Ruby On Rails,Ajax,Ruby On Rails 4,假设我的js.erb文件在根页面(application.html.erb)上发出ajax请求。我的ajax.get能否从应用程序索引中提取包含当前用户的变量 为什么不直接在js.erb文件中访问helper方法呢 <%= current_user %> 你签了吗?方法假定您正在使用Desive进行身份验证。听起来您想用JSON响应。我建议您阅读本指南: <%= current_user %> def index @trackers =current_user.t
为什么不直接在js.erb文件中访问helper方法呢
<%= current_user %>
你签了吗?方法假定您正在使用Desive进行身份验证。听起来您想用JSON响应。我建议您阅读本指南:
<%= current_user %>
def index
@trackers =current_user.trackers.where(viewed: false).count
@user = current_user if current_user && signed_in?
end