我的申请有问题。有保龄球比赛。其中生成最终结果的名称。我在插入数据库时遇到问题
看法:
<%= form_for player_index_path(@player) do |f|%>
<div class="text_field">
<p>
<%= f.label "Spelare namn" %>
<%= f.text_field :name %>
</p>
<p>
<%= f.submit "Lägg till spelare"%>
</p>
</div>
<%end%>
类 Player < ActiveRecord::Base attr_accessible :name belongs_to :result end
控制器:
def create
@player = Player.new(params[:player])
if @player.save
render :action => "index"
else
render :action => "new"
end
end
迁移:
class CreatePlayers < ActiveRecord::Migration
def change
create_table :players do |t|
t.string "name"
t.references :results
t.timestamps
end
结束结束