ActionView :: Template :: Error(缺少属性:col1)

时间:2011-12-22 13:36:44

标签: ruby ruby-on-rails-3

查看:

<%= link_to "Link", {:action => "AjaxView",:col => "colname"}, :update => "Ajaxcall", :remote => true %>

控制器:

def AjaxView
   @vars= Var.find(:all,:conditions => { :varName=> "one" },:select=>(params[:col]))
   respond_to do |format|
      format.js { render :layout=>false }
  end
end

AjaxView.js

$("#3").text("<%= escape_javascript(render(:partial => "var", :collection => @vars)) %>");

_var.html.erb

<%= var.col1 %>

我收到以下错误: ActionView :: Template :: Error(缺少属性:col1):     1:&lt;%= var.col1%&gt;

1 个答案:

答案 0 :(得分:1)

 <%= @var[0].col %> is the right answer