Add peripheral.rb
parent
6e7b2c69a0
commit
3dc5d520b6
|
@ -6,6 +6,7 @@ class Device < ActiveRecord::Base
|
|||
has_many :sequences, dependent: :destroy
|
||||
has_many :regimens, dependent: :destroy
|
||||
has_many :plants, dependent: :destroy
|
||||
has_many :peripherals, dependent: :destroy
|
||||
has_one :planting_area, dependent: :destroy
|
||||
|
||||
validates_uniqueness_of :name
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class Peripheral < ActiveRecord::Base
|
||||
belongs_to :device
|
||||
end
|
|
@ -11,6 +11,7 @@ FarmBot::Application.routes.draw do
|
|||
resources :planting_area, only: [:create, :destroy]
|
||||
resources :sequences, only: [:create, :update, :destroy, :index, :show]
|
||||
resources :schedules, only: [:create, :update, :destroy, :index]
|
||||
resources :peripherals, only: [:create, :update, :destroy, :index]
|
||||
resources :corpuses, only: [:index, :show]
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
class CreatePeripherals < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :peripherals do |t|
|
||||
t.references :device, index: true, foreign_key: true
|
||||
t.integer :pin
|
||||
t.integer :mode
|
||||
t.string :label
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
14
db/schema.rb
14
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20161011221406) do
|
||||
ActiveRecord::Schema.define(version: 20161028175744) do
|
||||
|
||||
create_table "devices", force: :cascade do |t|
|
||||
t.integer "planting_area_id", limit: 4
|
||||
|
@ -19,6 +19,17 @@ ActiveRecord::Schema.define(version: 20161011221406) do
|
|||
t.string "webcam_url", limit: 255
|
||||
end
|
||||
|
||||
create_table "peripherals", force: :cascade do |t|
|
||||
t.integer "device_id", limit: 4
|
||||
t.integer "pin", limit: 4
|
||||
t.integer "mode", limit: 4
|
||||
t.string "label", limit: 255
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_index "peripherals", ["device_id"], name: "index_peripherals_on_device_id", using: :btree
|
||||
|
||||
create_table "planting_areas", force: :cascade do |t|
|
||||
t.integer "width", limit: 4
|
||||
t.integer "length", limit: 4
|
||||
|
@ -98,4 +109,5 @@ ActiveRecord::Schema.define(version: 20161011221406) do
|
|||
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
|
||||
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
|
||||
|
||||
add_foreign_key "peripherals", "devices"
|
||||
end
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
FactoryGirl.define do
|
||||
factory :peripheral do
|
||||
device nil
|
||||
pin 1
|
||||
mode 1
|
||||
label "MyString"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
describe Peripheral do
|
||||
it 'just is, OK?' do\
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue