diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 898ed5da2..981808017 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -341,6 +341,7 @@ class ProjectsController < ApplicationController @course = Course.new @course.extra=params[:project][:identifier] @course.safe_attributes = params[:project][:course] + @course.tea_id = User.current.id @course.save # project = ProjectInfo.create(:user_id => User.current.id, :project_id => @project.id) # project_status = ProjectStatus.create(:project_id => @project.id) diff --git a/app/models/course.rb b/app/models/course.rb index f5e00a09a..4d0fe8378 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -3,8 +3,9 @@ class Course < ActiveRecord::Base attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state belongs_to :project, :class_name => 'Project', :foreign_key => :extra + belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 has_many :bid - validates_presence_of :time + validates_presence_of :state safe_attributes 'extra', 'time', 'name', diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 83d4f4add..76ac17079 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -69,11 +69,14 @@
- + + + - - + + +
课程学时:<%= @course.state%>课程口令:<%= @course.state%>
课程学时:<%= @course.time%>
主讲老师:<%= @course.teacher.name %>
@@ -85,12 +88,18 @@
+ <% if @project.description.size>0 %>
<%= textilizable @project.description %>
+ <% else %> +
+ <%= l(:label_course_description_no) %> +
+ <% end %>
- <%= l(:label_create_time) %>:<%= @project.created_on %> + <%= l(:label_create_time) %>:<%= format_time(@project.created_on) %>
diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 896a8dd61..818e16b7c 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -110,8 +110,8 @@