0
以下是我的控制器代碼和視圖代碼。該視圖顯示一個遊戲列表,我想添加一個遊戲到同一視圖中的現有表。我在後續程序中遇到了一些問題。任何建議或任何人都可以指出我可能做錯了什麼?我如何在rails中進行POST?
class GamesController < ApplicationController
# GET /games
def index
@games = []
client = Games::Client.new
@games =client.get_games
if @games.blank?
render_404
end
if params[:name]
client.create_games params[:name]
end
end
end
%nav.navigation-bar.clearfix{:role => "navigation"}
%h3.reader-details Game tools
%a.home{:href => root_path, :role => "link", :title => "Home"}Home
%body
%section.form
%form.standard{:action => "/games", :method => "post"}
%input{type: 'text', name: 'name', class: 'text'}
%input.primary-action{type: 'submit', value: 'Add', class: 'button'}
.content
- if @games.present?
%table.games
%thead
%tr
%th type
%th id
%tbody
- @games.each do |game|
%tr
%td= game['type']
%td= game['id']
%a= link_to "Back", root_path