Making the user just book one training not more - ruby-on-rails

Im making an application where an user can book a hour of training. I want to give the app the restriction of when an user has already booked one hour of training, it cant book more trainings, at least he deletes it or the book expires.
My code is:
Bookings controller:
Class BookingsController < ApplicationController
before_action :load_training, only: [:create]
def new
#booking = Booking.new
#training = Training.find(params[:training_id])
#booking.training_id
end
def create
#booking = #training.bookings.build(booking_params)
#booking.user = current_user
if #booking.save
flash[:success] = "Book done"
redirect_to trainings_path
else
render 'new'
end
end
def index
#bookings = Booking.where(training_id: params[:training_id])
end
def destroy
#booking = Booking.find(params[:id])
#booking.destroy
flash[:success] = "Book deleted"
redirect_to trainings_path
end
private
def booking_params
params.require(:booking).permit(:user_id, :training_id)
end
def load_training
#training = Training.find(params[:training_id])
end
end
Booking model:
class Booking < ApplicationRecord
belongs_to :user
belongs_to :training
default_scope -> { order(created_at: :desc) }
validates :user_id, presence: true
validates :training_id, presence: true
end
My routes.rb:
Rails.application.routes.draw do
root 'static_pages#home'
get '/signup', to: 'users#new'
get '/contact', to: 'static_pages#contact'
get '/about', to: 'static_pages#about'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
resources :account_activations, only: [:edit]
resources :password_resets, only: [:new, :create, :edit, :update]
resources :trainings do
resources :bookings
end
resources :users
end
Index of training view:
<h1>Hours</h1>
<ul class="trainings">
<% #trainings.each do |training| %>
<li>
<%= link_to training.hour, training_path(training) %>
</li>
<% end %>
</ul>
Show of training view:
<div class="row">
<section>
<h1>
HOUR: <%= #training.hour %>
</h1>
</section>
<section>
<h1>
SLOTS: <%= #training.slots %>
</h1>
</section>
<center>
<%= render 'bookings/booking_form' if logged_in? %>
<%= render 'bookings/index_bookings' if logged_in? %>
</center>
Booking_form.html.erb view:
<% unless current_user?(#user) %>
<% if current_user.is_booked(#training) %>
<%= link_to "Delete book", training_booking_path(#training), method: "delete", data: { confirm: 'Are you certain you want to delete this?' }, class: "btn btn-primary" %>
<% else %>
<%= link_to "Book", new_training_booking_path(#training), class: "btn btn-primary" %>
<% end %>
<% end %>
Im recieving the following error:
ActiveRecord::RecordNotFound in BookingsController#destroy
Couldn't find Booking with 'id'=1
Parameters:
{"_method"=>"delete",
"authenticity_token"=>"0uUXRwZdbhaKl16QxDi1HCM4H8IwEvGuoFOoxmkHhowoAUgZnlWPybck9DEbCKHh42SqXs3vtc01IRTqbx05wA==",
"training_id"=>"1", "id"=>"1"}
I would like to know why the method does not get the booking_id
When i try to see a training hour:
Started GET "/trainings/1" for 127.0.0.1 at 2017-03-11 01:03:23 -0400
Processing by TrainingsController#show as HTML
Parameters: {"id"=>"1"}
Training Load (0.1ms) SELECT "trainings".* FROM "trainings" WHERE "trainings"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
Rendering trainings/show.html.erb within layouts/application
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
Rendered bookings/_booking_form.html.erb (2.3ms)
Rendered trainings/show.html.erb within layouts/application (4.0ms)
Completed 500 Internal Server Error in 6ms (ActiveRecord: 0.2ms)
ActionView::Template::Error (No route matches {:action=>"show", :controller=>"bookings", :id=>nil, :training_id=>"1"} missing required keys: [:id]):
2: <% if current_user.not_booked(#training) %>
3: <%= link_to "Reservar", new_training_booking_path(#training), class: "btn btn-primary" %>
4: <% else %>
5: <%= link_to "Eliminar reserva", training_booking_path(#training, #booking), method: :delete,
6: data: { confirm: 'Are you certain you want to delete this?' }, class: "btn btn-primary" %>
7: <% end %>
8: <% end %>
Training model:
class Training < ApplicationRecord
has_many :users, through: :bookings
has_many :bookings
def can_book?
bookings.count < cantidad
end
end
Training controller:
class TrainingsController < ApplicationController
def show
#training = Training.find(params[:id])
end
def index
#trainings = Training.all
end
end
Thanks

In this line:
<%= link_to "Delete book", training_booking_path(#training), method: "delete", data: { confirm: 'Are you certain you want to delete this?' }, class: "btn btn-primary" %>
I think the path training_booking_path(#training) should also contain the #booking instance variable because of the nested routes.
So it should be training_booking_path(#training, #booking), method: :delete, etc.
You'd have to have #booking available in your view where the form shows up
I would use rake routes in your console to confirm the correct path and which resource ids need to be passed in
EDIT:
your trainings controller show action needs to have bookings available as an instance variable:
def show
#training = Training.find(params[:id])
#bookings = #training.bookings
end
Then in your training show view where the form resides, you need to loop over the #bookings and include an individual delete link for each:
<% #bookings.each do |booking| %>
<%= link_to "Delete book", training_booking_path(booking.training, booking), method: :delete, data: { confirm: 'Are you certain you want to delete this?' }, class: "btn btn-primary" %>
<% end %>

Related

Delete method Rails - No route matches [GET] "/bookmarks/11"

My delete method for bookmarks does not seem to work, is this a problem with rails 7 or am I doing something wrong. It states that there is no Get method. I am using turbo-pack methods vs webpack
below is all relevant documents
routes.rb
Rails.application.routes.draw do
root 'lists#index'
resources :lists, except: [:edit, :update] do
resources :bookmarks, only: [:new, :create]
end
resources :bookmarks, only: :destroy
end
bookmarks_controller.rb
class BookmarksController < ApplicationController
before_action :set_bookmark, only: :destroy
before_action :set_list, only: [:new, :create]
def new
#bookmark = Bookmark.new
end
def create
#bookmark = Bookmark.new(bookmark_params)
#bookmark.list = #list
if #bookmark.save
redirect_to list_path(#list)
else
render :new
end
end
def destroy
#bookmark.destroy
redirect_to list_path(#bookmark.list), status: :see_other
end
private
def bookmark_params
params.require(:bookmark).permit(:comment, :movie_id)
end
def set_bookmark
#bookmark = Bookmark.find(params[:id])
end
def set_list
#list = List.find(params[:list_id])
end
end
show.html.erb
<div class="row">
<% #list.movies.each do |movie|%>
<% bookmark = Bookmark.find_by(list: #list, movie: movie) %>
<div class="col-12 col-lg-4">
<div class="card text-center text-white" style="background-color:#ffa82e00;">
<div class="card photo" class="card-img-top">
<%= image_tag(movie.poster_url, class: "card-img-top" )%>
<div class="card-body">
<h5 class="card-title text-dark"><%= movie.title%></h5>
<p class="card-text text-body"><%= movie.overview %></p>
<p class="card-text text-body"><%= bookmark.comment%></p>
<%= link_to "delete", bookmark_path(bookmark), data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to remove #{movie.title} from your #{#list.name} list"}, class: 'text-danger' %>
</div>
</div>
</div>
</div>
<% end %>
<%= link_to "Bookmark now", new_list_bookmark_path(#list), class: "btn btn-primary" %>
Just use button_to instead which creates an actual form element and works even without relying on JavaScript:
<%= button_to "delete",
bookmark,
data: {
turbo_confirm: "Are you sure you want to remove #{movie.title} from your #{#list.name} list"
},
method: :delete,
class: 'text-danger'
%>
This has additional benefits to accessibility and the historical reasons why Rails used links and JS to turn clicking a link into a form submission are largely irrelevant in 2023. This is a feature that Turbo just provides for backwards compatibly.
As to why it doesn't work:
Turbo isn't properly included.
You have an error in your javascript thats preventing the event handler from doing its job.
You have a conflicting event handler.
It's the wrong phase of the planets...
I think it's because you are using link_to which will send a GET request. Try using button_for instead.

How to fix "undefined method" error in destroy function

I am creating a page where a logged in user can view a list of their upcoming reservations and cancel a reservation if need be.
I've tried this as the destroy function:
def destroy
#trip = Reservation.find(params[:id])
#trip.destroy
flash[:alert] = "This booking has been cancelled."
redirect_to your_trips_path
end # destroy/ cancel a booking
which produces the following error
undefined method `space_reservation' for #<#<Class:0x00007f8198a191d8>:0x00007f8195341160>
Did you mean? space_reservations_url
Here is the relevant code in the controller.rb
class ReservationsController < ApplicationController
before_action :authenticate_user!
before_action :set_reservation, only: [:approve, :decline, :destroy]
...
def your_trips
#today = DateTime.now
#trips = current_user.reservations.order(start_date: :desc)
end
def destroy
#reservation = Reservation.find(params[:id])
#reservation.destroy
flash[:alert] = "This booking has been cancelled."
redirect_to your_trips_path
end # destroy/ cancel a booking
Routes.rb
resources :spaces, except: [:edit] do
member do
get 'listing'
delete :delete_image_attachment
get 'preload'
get 'preview'
get 'get_dates'
get 'get_times'
put :deactivate
put :activate
get 'browse_spaces'
end
resources :reservations, only: [:create]
resources :calendars
end
resources :reservations, only: [:approve, :decline, :destroy] do
member do
post '/approve' => "reservations#approve"
post '/decline' => "reservations#decline"
delete 'destroy'
end
end
View
<div class="panel-body">
<% #trips.each do |trip| %>
...
<div class="col-md-3 text-right trips-index">
<% if trip.start_date && trip.end_date > #today %>
<%= link_to 'Cancel',
space_reservation(trip),
method: :delete,
class:"btn btn-danger",
data: { confirm: 'Are you sure?' } %>
<% end %>
</div>
</div>
<hr/>
<% end %>
</div>
I would like for the reservation to be deleted when the cancel button is clicked and to no longer appear in the list of reservations. Does anyone spot what I did wrong in the function? Thanks.
The error message says that the space_reservation method is undefined.
In your view, you called that undefined method here:
<%= link_to 'Cancel',
space_reservation(trip),
method: :delete,
class:"btn btn-danger",
data: { confirm: 'Are you sure?' } %>
<% end %>
Assuming everything else works, if you either create the space_reservation method or find another way to resolve the issue, then it should work.

The action 'destroy' could not be found for ListingsController

UPDATE - I'VE NOW SOLVED THIS PROBLEM - I created a partial for the each Course item and rendered them from the main listing view. Thanks for all your help, I'm not really sure why it worked but it did END OF UPDATE
Apologies if this looks like a repeat posting but I've tried applying solutions to similar questions and they haven't worked, I'm stuck! Any suggestions welcomed, thank you.
Problem
I have a 'Courses' model which belongs to a 'Listings' model. The courses are created and deleted on a page belonging to Listing i.e. "/listing/2/courses"
Error Message
No route matches [DELETE] "/listings/2/courses"
Courses Controller def destroy detail
class CoursesController < ApplicationController
before_action :authenticate_user!, except: [:show]
before_action :set_listing
before_action :set_course, except: [:index, :new, :create]
def destroy
#course = #listing.courses.find(params[:id])
#course.destroy
flash[:notice] = "Course deleted!"
redirect_back(fallback_location: request.referer)
end
private
def set_course
#listing = Listing.find(params[:listing_id])
#course = Course.find(params[:id])
end
def set_listing
#listing = Listing.find(params[:listing_id])
end
def course_params
params.require(:course).permit(:name, :curriculum_type, :summary, :address, :course_places, :start_date, :finish_date, :price)
end
end
listing/listingID/courses page detail
<%= #listing.courses.each do |f| %>
<div class="jumbotron">
<ul>
<li>Name = <%= f.name %></li>
<li>Type of course = <%= f.curriculum_type %></li>
<li>Number of places = <%= f.course_places %></li>
<li>Start Date = <%= f.start_date %></li>
<li>Finish Date = <%= f.finish_date %></li>
<li>Price (£) = <%= f.price %></li>
<%= link_to "Delete Course", listing_courses_path(#listing, #course), method: :delete %>
</ul>
</div>
<% end %>
Routes.rb detail
resources :users, only: [:show]
resources :listings, except: [:edit] do
member do
get 'listing'
get 'pricing'
get 'description'
get 'photo_upload'
get 'amenities'
get 'location'
get 'courses'
end
resources :courses, except: [:edit] do
member do
get 'listing'
get 'pricing'
get 'description'
get 'photo_upload'
get 'amenities'
get 'location'
end
end
end
<%= link_to listing_course_path(#listing,f), :method => :delete, :data => { :confirm => 'Are you sure?' } %>
or try
<%= link_to listing_course_path(#listing,id: f.try(:id)), :method => :delete, :data => { :confirm => 'Are you sure?' } %>
route.rb
resources :listings do
resources :courses
end
By default, destroy method expects an ID as it's a member route. You are using listing/listingID/courses route without an ID. For that you need to define listing and/or courses as singular resources (read this) like:
resource :courses do
:
end
as described in this answer or make destroy a collection route like so:
resources :courses, except: [:edit] do
delete :destroy, on: :collection
:
rest...
end
Try and see if this works.
By the way, this looks a bit redundant as you are iterating over each #listing.courses and calling courses#destroy where you are destroying all the courses of #listing anyhow. So, why do #listing.courses.each in the first place. You should have either used a listing#destroy_courses method or remove #listing.courses.each iteration.
Update path in link_to to listing_course_path(#listing, #course) from listing_courses_path(#listing, #course)
<%= link_to "Delete Course", listing_course_path(#listing, f), method: :delete %>

Rails: When I click on edit in my partial it always edits the same id

I'm a newbie and as you will probably see from my files, I don't fully know what I'm doing :( . At the moment I have a user and a project model. A project belongs to a user, a user has many projects.
I have created a user profile page that shows all projects belonging to that user. I would like to give the user the chance to edit or delete the project directly from his profile. At the moment Delete seems to work and Edit only works if the user first clicks on "show" and then edits the project. But when the user clicks on edit from his profile, the project to be edited is not the one clicked.
This is my profile view (views/users/show):
<% provide(:title, #user.name) %>
<div class="row">
<aside class="col-md-4">
<section class="user_info">
<h1>
<%= #user.name %>
</h1>
</section>
</aside>
<div class="col-md-8">
<% if #user.projects.any? %>
<h3>Projects (<%= #user.projects.count %>)</h3>
<ol class="projects">
<%= render #projects %>
</ol>
<%= will_paginate #projects %>
<% end %>
</div>
</div>
This is the _project partial with the edit link:
<li id="project-<%= project.id %>">
<span class="title">
Title: <%= project.title %></span><br>
<span class="status">
<span class="user">
Submitted By: <%= link_to project.user.name, project.user %></span><br>
<span class="description">
Description: <%= project.description %></span><br>
<span class="status">
Status:<%= project.status %></span><br>
<span class="p_type">
Type: <%= project.p_type %></span><br>
<span class="timestamp">
Updated: <%= time_ago_in_words(project.updated_at) %> ago.
<% if current_user?(project.user) %>
<%= link_to "delete", project, method: :delete,
data: { confirm: "You sure?" } %>
<%= link_to "edit", edit_project_path %>
<%= link_to "New Project!", new_project_path %>
<% end %>
<!-- <%= link_to "show", project, method: :get %> -->
</span>
</li>
This is my projects controller:
class ProjectsController < ApplicationController
before_action :logged_in_user, only: [:create, :edit, :destroy]
before_action :correct_user, only: [:edit, :destroy]
def index
#projects = Project.paginate(page: params[:page])
end
def show
#project = Project.find(params[:id])
end
def new
#project = Project.new
end
def create
#project = current_user.projects.build(project_params)
if #project.save
flash[:success] = "Project created!"
redirect_to root_url
else
#feed_items = []
render 'new'
end
end
def edit
#project = Project.find params[:id]
end
def update
#project = Project.find params[:id]
#user = User.find(params[:id])
if #project.update(project_params)
flash[:success] = "Project updated"
redirect_to user_path(#user)
else
render 'edit'
end
end
def destroy
#project.destroy
flash[:success] = "Project deleted"
redirect_to request.referrer || root_url
end
private
def project_params
params.require(:project).permit(:description, :title, :status, :p_type)
end
def correct_user
#project = current_user.projects.find_by(id: params[:id])
redirect_to root_url if #project.nil?
end
end
My project model:
class Project < ApplicationRecord
belongs_to :user
default_scope -> { order(updated_at: :desc) }
validates :user_id, presence: true
validates :description, presence: true, length: { maximum: 250 }
validates :title, presence: true, length: { maximum: 60 }
validates :p_type, presence: true
validates :status, presence: true
end
My routes file:
Rails.application.routes.draw do
root 'static_pages#home'
get '/help', to: 'static_pages#help'
get '/about', to: 'static_pages#about'
get '/contact', to: 'static_pages#contact'
get '/signup', to: 'users#new'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
resources :users
resources :account_activations, only: [:edit]
resources :password_resets, only: [:new, :create, :edit, :update]
resources :projects
end
Lastly if it helps, when I do the edit operation, this is the trace:
Started GET "/projects/1/edit" for 86.44.57.230 at 2016-10-29 12:16:49 +0000
Cannot render console from 86.44.57.230! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by ProjectsController#edit as HTML
Parameters: {"id"=>"1"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
Project Load (0.2ms) SELECT "projects".* FROM "projects" WHERE "projects"."user_id" = ? AND "projects"."id" = ? ORDER BY "projects"."updated_at" DESC LIMIT ? [["user_id", 1], ["id", 1], ["LIMIT", 1]]
Project Load (0.2ms) SELECT "projects".* FROM "projects" WHERE "projects"."id" = ? ORDER BY "projects"."updated_at" DESC LIMIT ? [["id", 1], ["LIMIT", 1]]
Rendering projects/edit.html.erb within layouts/application
Rendered shared/_error_messages.html.erb (0.6ms)
Rendered projects/edit.html.erb within layouts/application (24.9ms)
Rendered layouts/_shim.html.erb (0.4ms)
Rendered layouts/_header.html.erb (1.0ms)
Rendered layouts/_footer.html.erb (0.4ms)
Completed 200 OK in 179ms (Views: 172.4ms | ActiveRecord: 0.7ms)
Also adding the edit form
<% provide(:title, "Edit Project") %>
<h1>Update your Project</h1>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= form_for(#project) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.label :title %>
<%= f.text_field :title, class: 'form-control' %>
<%= f.label :p_type %>
<%= f.select :p_type, ([['QuickWin', 'QuickWin'],
['Project', 'Project']]) %>
<%= f.label :status %>
<%= f.select :status, ([['Not Yet Started', 'Not Yet Started'],
['In Progress', 'In Progress'], ['In Testing', 'In Testing'],
['On Hold', 'On Hold'], ['Launched', 'Launched']]) %>
<div class="field">
<%= f.text_area :description, placeholder: "Briefly summarise the purpose of this project..." %>
</div>
<%= f.submit "Save changes", class: "btn btn-primary" %>
<% end %>
</div>
</div>
Thank you in advance for your help!
On the below row is missing what is the record you wanna change:
<%= link_to "edit", edit_project_path %>
Add to 'edit_project_path' the project reference:
<%= link_to 'edit', edit_project_path(project) %>
I hope this help you.
...
About the error "Couldn't find User with 'id'=424" on call #user = User.find(params[:id]) on your comment ...
When you click on submit you send a PUT action on controller projects_controller.rb on method update with params with a Project object.
In your projects_controller.rb, your method 'update' receive a Project object.
Here params must appear as
params = { ... project:{:title => '...' , :ptype => ..}, 'id' => XXX }
this 'id' is the project.id !!
projects_controller.rb file
def update
#project = Project.find params[:id]
#user = User.find(params[:id]) <= you try to find a User with project.id
I think you wanna find user in join with this 'project'.
#user = #project.user

Rails - Votes not saving, and creating button that does not submit?

so I'm trying to create a video game review website for practice.
A game has many reviews, and votes. The idea is, in order to post a review, you must vote "Good" or "Bad" first, THEN submit a review. You can't post a text review without voting.
I'm trying to do this without the acts_as_voteable gem...
The data format for votes is boolean. "Good" is true, "Bad" is false.
How do I get the votes to save? below are my routes.rb, _review partial, reviews controller, and show page.
many thanks guys :)
edit****: also I'm trying to only one vote per user. I was thinking of using a token variable which equals to 1, and when a vote is cast, the token is -1. Is that a good approach? But the data type for vote is boolean, so how would that work -- or should I change the data type for vote from boolean to integer?
edit#2 -- so I added :vote into my params.
routes.rb
upvote_game_review_path
POST /games/:game_id/reviews/:id/upvote(.:format) reviews#upvote
downvote_game_review_path
POST /games/:game_id/reviews/:id/downvote(.:format) reviews#downvote
Rails.application.routes.draw do
devise_for :users
root "games#index"
resources :games do
resources :news
resources :reviews, except: [:show, :index] do
member do
post "upvote"
post "downvote"
end
end
end
resources :platforms
resources :genres
end
reviews_controller.rb
class ReviewsController < ApplicationController
before_action :set_review, only: [:show, :update, :edit, :destroy]
before_action :set_game
before_action :authenticate_user!
def new
#review = Review.new
end
def create
#review = Review.new(review_params)
#review.user_id = current_user.id
#review.game_id = #game.id
if #review.save
redirect_to #game
else
render "review"
end
end
def upvote
#review.vote.create = true
redirect_to #game
end
def downvote
#review.vote.create
#review.vote = false
redirect_to #game
end
def edit
#review.update(review.params)
end
def destroy
#review.destroy
redirect_to #game
end
private
def set_review
#review = Review.find(params[:id])
end
def set_game
#game = Game.find(params[:game_id])
end
def review_params
params.require(:review).permit(:comment, :vote)
end
end
_review partial <-- to create a new review
<%= form_for [#game, #reviews.new] do |r| %>
<h3 class="post_review">Review this game</h3>
<p>
<%= r.text_area :comment %>
</p>
<p>
<%= button_to "Good", upvote_game_review_path(#game.id, r) %>
</p>
<p>
<%= button_to "Bad", downvote_game_review_path(#game.id, r) %>
</p>
<p>
<%= r.hidden_field :game_id, value: #game.id %>
<p>
<%= r.submit %>
<% end %>
show.html.erb
<p><%= link_to "<< Home", games_path %></p>
<span><%= link_to "Edit", edit_game_path(#game) %></span>
<span><%= link_to "Delete", game_path(#game), method: :delete %></span>
<div class="game_summary">
<h2><%= #game.title %></h2>
<%= image_tag #game.image %>
<p>Release Date: <%= #game.release_date %> </p>
<p>Genre: <%= #game.genre_id %> </p>
<p>Platforms: <%= #game.platform_id %></p>
</div>
<%= link_to "Add News", new_game_news_path(#game) %>
<h2>News & Articles</h2>
<%= link_to "view all", game_news_index_path(#game) %>
<% #news.each do |n| %>
<ol>
<li><%= link_to n.title, game_news_path(#game.id, n.id) %></li>
</ol>
<% end %>
<div class="game_review submit">
<%= render "review" %>
</div>
<% #reviews.each do |review| %>
<p><%= review.comment %></p>
<p><%= link_to "delete", game_review_path(#game.id, review.id), method: :delete %></p>
<% end %>
You don't specify which review you're loading in. The reason is here:
before_action :set_review, only: [:show, :update, :edit, :destroy]
You don't pull in the request's review instance when you go to either of those actions. Further, it doesn't look like you're actually saving them.
So, two things I'd recommend:
Add those methods to your before_action:
before_action :set_review, only: [:show, :update, :edit,
:destroy, :upvote, :downvote]
(May not be necessary, write tests to confirm this!) Actually save the entity after you've changed its value.
def upvote
#review.vote.create = true
#review.save
redirect_to #game
end
def downvote
#review.vote.create unless #review.vote
#review.vote = false
#review.save
redirect_to #game
end

Resources