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 %>
これは conf.rb での検索です:
def self.search(search)
if search
q = "%#{search}%"
where('machine_name LIKE ? OR
machine_brand LIKE ? OR
machine_model LIKE ? OR
control_unit_brand LIKE ? OR
control_unit_model LIKE ? OR
tool_axis_x LIKE ? OR
tool_axis_y LIKE ? OR
tool_axis_z LIKE ? OR
rotary_axis_number LIKE ? OR
linear_axis_number LIKE ? OR
description LIKE ? OR
developer_id LIKE ? OR
updated_at LIKE ? OR',
q,q,q,q,q,q,q,q,q,q,q,q,q)
else
scoped
end
end
これは、application_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行目は次のとおりです。
何が問題で、どうすれば修正できますか?