Compare commits
No commits in common. "65982460768d4a5136bb92681938e911ff93c3c8" and "833307d9e6ff135847e3277e567558c7dff8aa2f" have entirely different histories.
6598246076
...
833307d9e6
5 changed files with 2 additions and 42 deletions
|
@ -5,7 +5,7 @@ ARG RUBY_PATCH=5
|
||||||
FROM ${BASE_IMAGE}:${ALPINE_VERSION}-${RUBY_VERSION}.${RUBY_PATCH}
|
FROM ${BASE_IMAGE}:${ALPINE_VERSION}-${RUBY_VERSION}.${RUBY_PATCH}
|
||||||
ENV RAILS_ENV production
|
ENV RAILS_ENV production
|
||||||
|
|
||||||
RUN apk add --no-cache libxslt libxml2 tzdata postgresql-libs libstdc++
|
RUN apk add --no-cache libxslt libxml2 tzdata --no-cache postgresql-libs libstdc++
|
||||||
|
|
||||||
VOLUME "/srv"
|
VOLUME "/srv"
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,8 @@ class ReadingsController < ActionController::API
|
||||||
head :bad_request
|
head :bad_request
|
||||||
end
|
end
|
||||||
|
|
||||||
# Registra una Raspberry junto con su llave pública
|
|
||||||
def raspberry
|
def raspberry
|
||||||
@raspberry ||= Raspberry.find_or_create_by!(name: params[:controller_id]).tap do |r|
|
@raspberry ||= Raspberry.find_or_create_by! name: params[:controller_id]
|
||||||
r.public_keys.find_or_create_by(content: request.headers[:'X-Public-Key'])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Procesa la transacción
|
# Procesa la transacción
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class PublicKey < ApplicationRecord
|
|
||||||
belongs_to :raspberry
|
|
||||||
|
|
||||||
validates_presence_of :content
|
|
||||||
validates_uniqueness_of :content
|
|
||||||
end
|
|
|
@ -3,7 +3,6 @@
|
||||||
class Raspberry < ApplicationRecord
|
class Raspberry < ApplicationRecord
|
||||||
has_many :readings
|
has_many :readings
|
||||||
has_many :arduinos
|
has_many :arduinos
|
||||||
has_many :public_keys
|
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_uniqueness_of :name
|
validates_uniqueness_of :name
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# Una Raspberry puede tener muchas llaves públicas
|
|
||||||
class CreatePublicKeys < ActiveRecord::Migration[6.1]
|
|
||||||
def up
|
|
||||||
create_table :public_keys, id: :uuid do |t|
|
|
||||||
t.timestamps
|
|
||||||
t.uuid :raspberry_id, index: true
|
|
||||||
t.string :content, null: false, unique: true
|
|
||||||
end
|
|
||||||
|
|
||||||
Raspberry.find_each do |r|
|
|
||||||
r.public_keys.create content: r.public_key
|
|
||||||
end
|
|
||||||
|
|
||||||
remove_column :raspberries, :public_key
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
add_column :raspberries, :public_key, :string
|
|
||||||
|
|
||||||
Raspberry.find_each do |r|
|
|
||||||
r.update public_key: r.public_keys.first.public_key
|
|
||||||
end
|
|
||||||
|
|
||||||
drop_table :public_keys
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue