以下是我的控制器代码和视图代码。该视图显示游戏列表,我想在同一视图中将游戏添加到现有表中。我在后期处理方面遇到了一些问题。任何建议或任何人都可以指出我可能做错了什么?
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