I want to create player object, without views for this object model, and without additional parameters. This is action create for this object:`
def create
@player = @tournament.players.new
if @player.save
redirect_to @tournament
render :nothing => true
end
end
This object also don't need additional parameters, because all parameters where set by default. As you can see, I tried resolve my problem with "render :nothing => true" but this don't work, and this is resoult:
Missing template players/new, application/new with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml, :jbuilder]}.
Update:
Routes.rb
resources :users
resources :tournaments do
resources :players
resources :rounds do
resources :duels
end
end
end
Server logs:
Started GET "/tournaments/1/players/new" for 127.0.0.1 at 2015-11-11 17:37:00 +0100 ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations" Processing by PlayersController#new as HTML Parameters: {"tournament_id"=>"1"} Tournament Load (0.5ms) SELECT "tournaments".* FROM "tournaments" WHERE "tournaments"."id" = ? LIMIT 1 [["id", 1]] Completed 500 Internal Server Error in 86ms (ActiveRecord: 1.3ms)
ActionView::MissingTemplate (Missing template players/new, application/new with {:locale=>[:en], :formats=>[:html, :xml], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml, :jbuilder]}. Searched in: * "/home/adam/workspace/tc/app/views" * "/home/adam/.rvm/gems/ruby-2.2.2/gems/devise-3.4.1/app/views" ):
Started GET "/tournaments/1/players/new" for 127.0.0.1 at 2015-11-11 17:37:01 +0100 Processing by PlayersController#new as HTML Parameters: {"tournament_id"=>"1"} Tournament Load (0.1ms) SELECT "tournaments".* FROM "tournaments" WHERE "tournaments"."id" = ? LIMIT 1 [["id", 1]] Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.1ms)
ActionView::MissingTemplate (Missing template players/new, application/new with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml, :jbuilder]}. Searched in: * "/home/adam/workspace/tc/app/views" * "/home/adam/.rvm/gems/ruby-2.2.2/gems/devise-3.4.1/app/views" ):
Player create button, rendered in action tournaments#index: (probably problem starts here)
%td= link_to 'Join', new_tournament_player_path(tournament), class: "btn btn-primary btn-md"
How can I resolve this problem?
/players/create.html.erb
unless your controller redirects or renders explicitly (likerender :nothing => true
). Check the server logs if your create action is even being called. It might help if you include the exact steps you performed and your routes.rb – max