parent
0b1ec7a1c5
commit
337885503e
|
@ -4,6 +4,7 @@ class Course < ActiveRecord::Base
|
|||
attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password
|
||||
belongs_to :project, :class_name => 'Project', :foreign_key => :extra # 定义一个project方法, 该方法通过extra来调用project表
|
||||
belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表
|
||||
belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表
|
||||
has_many :bid
|
||||
validates_presence_of :password, :term
|
||||
safe_attributes 'extra',
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
class School < ActiveRecord::Base
|
||||
attr_accessible :name, :province
|
||||
has_many :courses
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
class RemoveCityFromSchools < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :schools, :city
|
||||
end
|
||||
end
|
|
@ -1,12 +1,10 @@
|
|||
class CreateSchools < ActiveRecord::Migration
|
||||
|
||||
def change
|
||||
create_table :schools do |t|
|
||||
t.string :name
|
||||
t.string :province
|
||||
t.string :city
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddSchoolidToCourses < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :courses, :school_id, :integer
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140319092720) do
|
||||
ActiveRecord::Schema.define(:version => 20140320022724) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -173,6 +173,7 @@ ActiveRecord::Schema.define(:version => 20140319092720) do
|
|||
t.string "setup_time"
|
||||
t.string "endup_time"
|
||||
t.string "class_period"
|
||||
t.integer "school_id"
|
||||
end
|
||||
|
||||
create_table "custom_fields", :force => true do |t|
|
||||
|
@ -598,8 +599,10 @@ ActiveRecord::Schema.define(:version => 20140319092720) do
|
|||
end
|
||||
|
||||
create_table "schools", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "province"
|
||||
t.string "name"
|
||||
t.string "province"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "seems_rateable_cached_ratings", :force => true do |t|
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
one:
|
||||
name:
|
||||
province: MyString
|
||||
|
||||
two:
|
||||
name:
|
||||
province: MyString
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class SchoolTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in New Issue