diff --git a/app/controllers/gathers_controller.rb b/app/controllers/gathers_controller.rb index fe58618..001c323 100644 --- a/app/controllers/gathers_controller.rb +++ b/app/controllers/gathers_controller.rb @@ -46,6 +46,7 @@ class GathersController < ApplicationController redirect_to @gather end + # FIXME: Use gatherers.update def pick @gatherer = @gather.gatherers.find(params[:player]) raise AccessError unless @gatherer.can_update? cuser, params diff --git a/app/models/gatherer.rb b/app/models/gatherer.rb index 25bf8eb..3d418f4 100644 --- a/app/models/gatherer.rb +++ b/app/models/gatherer.rb @@ -30,7 +30,7 @@ class Gatherer < ActiveRecord::Base #attr_protected :id attr_accessor :confirm, :username - cattr_accessor :skip_callbacks + attr_accessor :skip_callbacks scope :team, -> (team) { where(team: team) } scope :of_user, -> (user) { where(user_id: user.id) } @@ -83,7 +83,7 @@ class Gatherer < ActiveRecord::Base def validate_username if username - if u = User.where(username: username).exists? + if (u = User.where(username: username).first) self.user = u else errors.add(:username, t(:gatherer_wrong_username)) @@ -171,6 +171,6 @@ class Gatherer < ActiveRecord::Base end def self.params(params, cuser) - params.require(:gatherer).permit(:status, :user_id, :gather_id, :team, :votes) + params.require(:gatherer).permit(:status, :username, :user_id, :gather_id, :team, :votes) end end diff --git a/app/views/gatherers/_list.html.erb b/app/views/gatherers/_list.html.erb index 62e9606..0409ccf 100644 --- a/app/views/gatherers/_list.html.erb +++ b/app/views/gatherers/_list.html.erb @@ -5,7 +5,7 @@ <%= if team.nil? then "Lobby" else team == 1 ? "Marines" : "Aliens" end %> -<%= form_tag "/gathers/pick/#{@gather.id}" do %> +<%= form_tag pick_gather_path(@gather) do %>