diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 2b9ec4631..3bbfa1705 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -203,7 +203,7 @@ class GamesController < ApplicationController next_game = @game.next_game next_game.update_attributes(:status => 0, :open_time => Time.now) if next_game.status == 3 - redirect_to myshixun_game_path(next_game, :myshixun_id => @myshixun.id) + redirect_to myshixun_game_path(next_game, :myshixun_id => @myshixun) end diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index fe0dadbad..eb1c62a8a 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -51,7 +51,7 @@ class MyshixunsController < ApplicationController private # Find myshixun of id params[:id] def find_myshixun - @myshixun = Myshixun.find(params[:id]) + @myshixun = Myshixun.find_by_identifier(params[:id]) rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index ce0e08623..cd7a035a3 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -6,6 +6,11 @@ class Myshixun < ActiveRecord::Base has_many :games, :dependent => :destroy, :order => "games.id ASC" belongs_to :shixun + # id 转换成 identifier + def to_param + identifier + end + # 当前任务:一个实训中只可能一个未完成任务(status 0或1只会存在一条记录) # status:0 可以测评的,正在测评的 # 如果都完成,则当前任务为最后一个任务 diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 9cd7c320a..f071f23dc 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -9,8 +9,6 @@ class Shixun < ActiveRecord::Base has_many :myshixuns # id 转换成 identifier - # 如果是整数就去ID,否则就取login - # 含有特殊符号的则显示ID def to_param identifier end diff --git a/app/views/shixuns/_form.html.erb b/app/views/shixuns/_form.html.erb index fc1ce97f8..b8a2176d1 100644 --- a/app/views/shixuns/_form.html.erb +++ b/app/views/shixuns/_form.html.erb @@ -33,7 +33,7 @@