class CreateUserAndAssistant < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.timestamps
end
create_table :assistants do |t|
t.string :name
t.timestamps
end
create_table :users_assistants, id: false do |t|
t.belongs_to :user, index: true
t.belongs_to :assistant, index: true
end
end
end
class User < ActiveRecord::Base
has_and_belongs_to_many :assistants
end
class Assistant < ActiveRecord::Base
has_and_belongs_to_many :users
end
start_time = DateTime.strptime(params[:event][:start_time],'%s') + 1.day