我试图为 ebm 设置一个虚拟属性:
<%= form_for Ebm.new do |f| %>
<td> <%= f.text_field :ebm_findid %></td>
......
在我的 ebm 模型中:
class Ebm < ActiveRecord::Base
attr_accessible :content, :extra, :number, :text
def ebm_findid(name)
self.ebm_id = Ebm.find_by_name(name)
end
end
但不知何故我得到了错误:
ArgumentError in Categories#index
Showing C:/Sites/ruble21.07abends/app/views/ebms/_favorite.html.erb where line #21 raised:
wrong number of arguments (0 for 1)
Extracted source (around line #21):
18: <% end %>
19: <tr>
20: <%= form_for Ebm.new do |f| %>
21: <td> <%= f.text_field :ebm_findid %></td>
我必须改变什么?