Rails - 如何创建form_for来更新记录列表?

时间:2014-10-16 21:42:36

标签: ruby-on-rails ruby haml form-for multiple-records

我有一支球队,球队有很多球员。我想在表单中显示播放器的名称,并允许用户更新这些名称。我怎么解决这个问题?我是rails的新手。代码在.html.haml中,当我添加text_field时它给了我一个错误。

.top
  = form_for @team, method: 'post', url: '/training/update_points' do |t|
    = button_to (t 'teams.training.save_changes'), { action: 'update_points', controller: 'training'}, method: 'post', class: 'submit-button-skill'
.columns-wrapper
  - unless @players.blank?
    %table.pretty
      %tr{class: 'row-wrapper'}
        %th{class: 'row-parameter-name'}= t 'teams.training.name'
      - for player in @team.players
        %tr{class: 'players-container'}
          %td{class: 'players-name-container'}
            .players-name2
              = t.text_field :name
            .players-number
              = "##{ player.number }"

0 个答案:

没有答案