Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Project Model
- class Project < ActiveRecord::Base
- has_and_belongs_to_many :clients
- end
- Clients Model
- class Client < ActiveRecord::Base
- has_one :user, :dependent => :destroy
- has_and_belongs_to_many :projects
- end
- clients_projects migration
- class CreateClientsProjects < ActiveRecord::Migration
- def self.up
- create_table :clients_projects, :id => false do |t|
- t.column :client_id, :integer
- t.column :project_id, :integer
- end
- end
- def self.down
- drop_table :clients_projects
- end
- end
- Clients Migration
- class CreateClients < ActiveRecord::Migration
- def self.up
- create_table :clients do |t|
- t.string :name, :null => false, :limit => '100'
- t.string :contact_name, :null => true, :limit =>'100'
- t.string :contact_last_name, :null => false, :limit => '100'
- t.string :contact_email, :null => false, :limit => '100'
- t.string :contact_phone, :null => false, :limit => '100'
- t.boolean :admin, :default => false
- t.timestamps
- end
- def self.down
- drop_table :clients
- end
- end
- Projects Migration
- class CreateProjects < ActiveRecord::Migration
- def self.up
- create_table :projects do |t|
- t.string :name, :null => false, :limit => '100'
- t.integer :duration, :null => false
- t.integer :progress, :default => 0
- t.timestamps
- end
- end
- def self.down
- drop_table :projects
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement