Compare commits

...

4 commits

Author SHA1 Message Date
f
d9faecf1bd ya no hace falta emparchar
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2022-03-14 17:33:18 -03:00
f
c019c5ba20 enviar a blazer 2022-03-14 17:32:54 -03:00
f
0612d16e6b la llave publica viene dentro del json 2022-03-14 17:32:28 -03:00
f
d4e35dbb5e registrar el número de serie de las raspberries 2022-03-14 17:32:11 -03:00
5 changed files with 38 additions and 20 deletions

View file

@ -2,9 +2,12 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
before_action :authenticate_user! before_action :authenticate_user!
def require_user def require_user
redirect_to root_path unless current_user redirect_to root_path unless current_user
end end
def index def index
redirect_to blazer_path
end end
end end

View file

@ -42,11 +42,22 @@ class ReadingsController < ActionController::API
head :bad_request head :bad_request
end end
# Registra una Raspberry junto con su llave pública # Registra una Raspberry junto con su llave pública.
#
# Como el número de serie se agregó después, queremos migrar ad-hoc
# las Raspberries que fueron registradas por su nombre y asociarles el
# número de serie apenas empiecen a actualizarse los nodemecu.
def raspberry def raspberry
@raspberry ||= Raspberry.find_or_create_by!(name: params[:controller_id]).tap do |r| @raspberry ||= begin
r.public_keys.find_or_create_by(content: request.headers[:'X-Public-Key']) r = Raspberry.find_by(serial_number: params[:serial_number])
end r ||= Raspberry.find_by(name: params[:controller_id])
r.tap do |r|
r.name = params[:controller_id]
r.serial_number = params[:serial_number]
r.public_keys.find_or_create_by(content: params[:public_key])
r.save
end
end
end end
# Procesa la transacción # Procesa la transacción

View file

@ -5,6 +5,6 @@ class Raspberry < ApplicationRecord
has_many :arduinos has_many :arduinos
has_many :public_keys has_many :public_keys
validates_presence_of :name validates_presence_of :name, :serial_number
validates_uniqueness_of :name validates_uniqueness_of :serial_number
end end

View file

@ -0,0 +1,18 @@
# frozen_string_literal: tru
# Agrega el número de serie de cada RPi
class AddSerialNumberToRaspberry < ActiveRecord::Migration[6.1]
def up
add_column :raspberries, :serial_number, :string
remove_index :raspberries, :name
add_index :raspberries, :serial_number, unique: true
end
def down
remove_index :raspberries, :serial_number
add_index :raspberries, :name, unique: true
remove_column :raspberries, :serial_number
end
end

View file

@ -1,14 +0,0 @@
--- rubygems.rb.orig
+++ rubygems.rb
@@ -764,10 +764,7 @@
def self.platforms
@platforms ||= []
if @platforms.empty?
- # XXX: Patched to avoid installing platform-specific gems with binaries
- # linked against glibc.
- @platforms = [Gem::Platform::RUBY]
- #@platforms = [Gem::Platform::RUBY, Gem::Platform.local]
+ @platforms = [Gem::Platform::RUBY, Gem::Platform.local]
end
@platforms
end