I have a problem with my application. There is a bowling game. which to generate the final result to a name. I have a problem to insert into my database
view:
<%= 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%>
class Player < ActiveRecord::Base attr_accessible :name belongs_to :result end
Controller:
def create
@player = Player.new(params[:player])
if @player.save
render :action => "index"
else
render :action => "new"
end
end
migrationen:
class CreatePlayers < ActiveRecord::Migration
def change
create_table :players do |t|
t.string "name"
t.references :results
t.timestamps
end
end end