Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby rails 3 ActiveRecord::语句无效_Ruby_Ruby On Rails 3_Search_Activerecord_Sqlite - Fatal编程技术网

Ruby rails 3 ActiveRecord::语句无效

Ruby rails 3 ActiveRecord::语句无效,ruby,ruby-on-rails-3,search,activerecord,sqlite,Ruby,Ruby On Rails 3,Search,Activerecord,Sqlite,我正在搜索index.html.erb,它给了我一个错误。 这是我的index.html.erb: <% provide(:title, 'All configurations') %> <h1>All configurations</h1> <%= form_tag conf_show_all_path, :method => 'get' do %> <%= hidden_field_tag :direction, params

我正在搜索index.html.erb,它给了我一个错误。 这是我的index.html.erb:

<% provide(:title, 'All configurations') %>
<h1>All configurations</h1>

<%= form_tag conf_show_all_path, :method => 'get' do %>
  <%= hidden_field_tag :direction, params[:direction] %>
  <%= hidden_field_tag :sort, params[:sort] %>
  <p>
    <%= text_field_tag :search, params[:search] %>
    <%= submit_tag "Search", :name => nil %>
  </p>
<% end %>

<table class="pretty" border="1" cellpadding="10">  
  <tr>
    <th><%= sortable("machine_name",       "M.Name")       %></th>
    <th><%= sortable("machine_brand",      "M.Brand")      %></th>
    <th><%= sortable("machine_model",      "M.Model")      %></th>
    <th><%= sortable("control_unit_brand", "C.Unit Brand") %></th>
    <th><%= sortable("control_unit_model", "C.Unit Model") %></th>
    <th><%= sortable("tool_axis_x",        "Axis X")       %></th>
    <th><%= sortable("tool_axis_y",        "Axis Y")       %></th>
    <th><%= sortable("tool_axis_z",        "Axis Z")       %></th>
    <th><%= sortable("rotary_axis_number", "R.Axis")       %></th>
    <th><%= sortable("linear_axis_number", "L.Axis")       %></th>
    <th><%= sortable "description"                         %></th>
    <th><%= sortable("name",               "Developer")    %></th>
    <th><%= sortable "updated_at"                          %></th>
  </tr>  

  <% for conf in @confs %>  
  <tr class="<%= cycle('oddrow', 'evenrow') -%>">
    <td><%= link_to conf.machine_name, conf %></td>
    <td><%= conf.machine_brand %></td>
    <td><%= conf.machine_model %></td>
    <td><%= conf.control_unit_brand %></td>
    <td><%= conf.control_unit_model %></td>
    <td><%= conf.tool_axis_x %></td>
    <td><%= conf.tool_axis_y %></td>
    <td><%= conf.tool_axis_z %></td>
    <td><%= conf.rotary_axis_number %></td>
    <td><%= conf.linear_axis_number %></td>
    <td><%= conf.description %></td>
    <td><%= conf.developer.name unless conf.developer_id.blank? %></td>
    <td><%= conf.updated_at %></td>
  </tr>
  <% end %>
</table>
<%= will_paginate @confs %>
这是应用程序_helper.rb中的可排序方法:

def sortable(column, title = nil)  
    title ||= column.titleize
    css_class = (column == sort_column) ? "current #{sort_direction}" : nil
    direction = (column == sort_column && sort_direction == "asc") ? "desc" : "asc"  
    link_to title, params.merge(:sort => column, :direction => direction, :page => nil), {:class => css_class}
end
最后,这是一个错误:

ActiveRecord::StatementInvalid in Confs#index
SQLite3::SQLException: no such column: name: SELECT  "confs".* FROM "confs"  ORDER BY name asc LIMIT 10 OFFSET 0
Extracted source (around line #30)
第30行是这样的:


问题是什么?我如何解决它?

好的,在
conf.rb
中搜索应该
updated\u at LIKE?
而不是
updated\u at LIKE?或者“
这是一个语法错误。关于这个问题,我把
confs\u controller.rb
中的
排序列
…params[:sort]:“name”
改为
…params[:sort]:“machine\u name”

@mehow,我当时觉得很困惑,以为这就是答案,我更新了我的答案,现在是真的,谢谢你的警告
ActiveRecord::StatementInvalid in Confs#index
SQLite3::SQLException: no such column: name: SELECT  "confs".* FROM "confs"  ORDER BY name asc LIMIT 10 OFFSET 0
Extracted source (around line #30)