Fix WikiPage.from_param
This commit is contained in:
@@ -164,7 +164,7 @@ class WikiController < ApplicationController
|
||||
@course = Course.from_param(params[:course_id])
|
||||
|
||||
if params[:id]
|
||||
@wiki_page = WikiPage.from_param(params[:id])
|
||||
@wiki_page = WikiPage.from_param(@course, params[:id])
|
||||
else
|
||||
@wiki_page = WikiPage.new(params[:wiki_page])
|
||||
end
|
||||
|
||||
@@ -88,6 +88,6 @@ class Course < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.from_param(param)
|
||||
param.is_numeric? ? Course.find(param) : Course.find_by_short_name(param)
|
||||
param.is_numeric? ? Course.find(param) : Course.find_by_short_name!(param)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,11 +79,11 @@ class WikiPage < ActiveRecord::Base
|
||||
canonical_title || id
|
||||
end
|
||||
|
||||
def self.from_param(param)
|
||||
def self.from_param(course, param)
|
||||
if param.is_numeric?
|
||||
WikiPage.find!(param)
|
||||
course.wiki_pages.find(param)
|
||||
else
|
||||
WikiPage.find_by_canonical_title!(param)
|
||||
course.wiki_pages.find_by_canonical_title!(param)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user