我在 Rails 应用程序中构建了一个 simple_form 表单,一切顺利:
<%= simple_form_for([@folha, @servico], html: {class: 'well form-horizontal'}) do |f| %>
<%= f.association :pessoa, label: 'Funcionário' %>
<%= f.input :funcao, label: 'Função',collection: @funcoes %>
<%= f.input :modulos, label: 'Módulos', input_html: {class: 'span4'} %>
<%= f.input :valor, label: 'Valor por hora', as: :string ,input_html: {class: 'span1'} %>
<%= f.input :horas, as: :string, input_html: {class: 'span1'} %>
<%= f.button :submit, 'Incluir', class: 'btn btn-primary' %>
<% end %>
要更改 f.association 下拉列表中的订单列表,我已经覆盖了 Pessoa.rb 中的默认 .all 方法:
def self.all
order :nome
end
然后在尝试渲染视图时出现此错误:
wrong number of arguments (1 for 0)
Extracted source (around line #5):
2: <h1>Preencher Pagamentos - Folha <%= "#{@folha.mes}/#{@folha.ano}" %> <small> <%= @folha.obs %> </small> </h1>
3: </div>
4: <%= simple_form_for([@folha, @servico], html: {class: 'well form-horizontal'}) do |f| %>
5: <%= f.association :pessoa, label: 'Funcionário' %>
6: <%= f.input :funcao, label: 'Função',collection: @funcoes %>
7: <%= f.input :modulos, label: 'Módulos', input_html: {class: 'span4'} %>
我认为最好找到一种在视图中对列表进行排序的方法。但我很好奇发生了什么
……