diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index aff63439e..65e3fe26a 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -21,6 +21,7 @@ require "fileutils"
class Attachment < ActiveRecord::Base
belongs_to :container, :polymorphic => true
belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'"
+ belongs_to :course, foreign_key: 'container_id', conditions: "attachments.container_type = 'Course'"
belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'"
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index e4a52826b..73c46b68b 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -40,9 +40,9 @@
- <%= link_to request.host()+"/course", :controller => 'courses', :action => 'course' %> |
+ <%= link_to request.host()+"/course", :controller => 'courses', :action => 'index' %> |
<%= link_to "主页", home_path %>
- > <%= link_to l(:label_course_practice), :controller => 'courses', :action => 'course' %>
+ > <%= link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %>
> <%= link_to @course.name, nil %> |
@@ -79,9 +79,6 @@
<% end %>
<% unless User.current.member_of?(@course) %>
-
-
- <%= watcher_link(@course, User.current) %>
<% end %>
<% end %>
diff --git a/db/migrate/20140605025302_migrate_course_attachments.rb b/db/migrate/20140605025302_migrate_course_attachments.rb
new file mode 100644
index 000000000..447624fa4
--- /dev/null
+++ b/db/migrate/20140605025302_migrate_course_attachments.rb
@@ -0,0 +1,17 @@
+class MigrateCourseAttachments < ActiveRecord::Migration
+ def self.up
+ # 原课程的资源数据迁移成新模式
+ Attachment.all.each do |attach|
+ if attach.container_type == "Project"
+ project = Project.find_by_id(attach.container_id)
+ if project && project.project_type == 1
+ attach.container_type= 'Course'
+ attach.save
+ end
+ end
+ end
+ end
+
+ def self.down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index dae888700..d559d41fb 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20140605025300) do
+ActiveRecord::Schema.define(:version => 20140605025302) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false