我們已經在我們的ERB文件錯誤,截屏在這裏Ruby on Rails的recieving錯誤:在表格第一個參數不能包含零或爲空
我們在games.html.erb一切如下
<h1>Games#game</h1>
<%= form_for(@game) do |f| %>
<div class="game-field">
<%= f.label :name %>
<%= f.text_field :name %>
</div>
<div class="actions">
<%= submit_tag "Game Created", :class=> "btn" %>
</div>
<% end %>
,這裏是控制器
class GamesController < ApplicationController
before_filter :store_location, :only => [:index, :show]
before_filter :require_user, :only => :show
before_filter :assign_game, :only => [:show, :destroy]
def index
@game = Game.new
end
def new
@game = Game.new
end
@game.add_player_from_user(current_user)
respond_to do |format|
format.html
format.json do render :json => {
:shouldStartNewRound => @game.is_ready_for_new_round?,
:shouldPassCards => @game.is_ready_to_pass?,
:isStartingFirstRound => @game.rounds.empty?,
:shouldReloadWaitAutoPlay => @game.should_reload?(current_player),
:shouldReloadAndJustWait => @game.should_reload_and_wait?(current_player)
}
end
end
end
def create
@game = Game.new(params[:game])
api_key = ""
api_secret = ""
@openTok = OpenTok::OpenTokSDK.new api_key, api_secret
session = @openTok.create_session request.remote_addr
@game.update_attributes(:session_id => session.session_id)
name = game[:name] # input from html
@game[:name] = name # setting input into db object (model)
if @game.save
redirect_to @game, alert: "game created"
else
render action: 'new'
end
end
def destory
@game.destory
redirect_to games_url
end
def reload
reload_partial
end
end
我們正努力創造一個局末平分的紙牌遊戲,我們有蜜蜂停留在這單一的問題。我還尋找其他類似的問題,人們已經問過,我們無法找到問題,它說我們必須把.new函數初始化數據。但錯誤仍然顯現。請幫助我們!
請檢查新的動作,有一些奇怪的事情,可能你沒有複製它的權利......要麼,或者你缺少'def update' – bosskovic
你可以更具體一點,我是非常新的紅寶石 –
請包括回調,它們可能是相關的。還請說明引發異常的操作。指數? – bosskovic