Last active
August 18, 2022 20:06
-
-
Save eirvandelden/172548c72aff03181418c2c04516ebd5 to your computer and use it in GitHub Desktop.
unknown attribute 'guid' for NfcTag. raise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "bundler" | |
Bundler.require | |
require "sinatra" | |
require "securerandom" | |
require "sinatra/activerecord" | |
require "debug" | |
set :database, { adapter: "sqlite3", database: "nfc_writer_helper.sqlite3" } | |
class NfcTag < ActiveRecord::Base | |
end | |
get "/:number" do | |
begin | |
tag = NfcTag.find number: params[:number] | |
rescue ActiveRecord::RecordNotFound | |
tag = NfcTag.create guid: SecureRandom.uuid, number: params[:number].to_i | |
end | |
"https://MY_URL.TEST/id/#{tag.guid}/?nfc_number=#{tag.number}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is auto-generated from the current state of the database. Instead | |
# of editing this file, please use the migrations feature of Active Record to | |
# incrementally modify your database, and then regenerate this schema definition. | |
# | |
# This file is the source Rails uses to define your schema when running `bin/rails | |
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to | |
# be faster and is potentially less error prone than running all of your | |
# migrations from scratch. Old migrations may fail to apply correctly if those | |
# migrations use external dependencies or application code. | |
# | |
# It's strongly recommended that you check this file into your version control system. | |
ActiveRecord::Schema.define(version: 2022_08_16_124058) do | |
create_table "nfc_tags", force: :cascade do |t| | |
t.string "guid" | |
t.integer "number" | |
t.datetime "created_at", precision: 6, null: false | |
t.datetime "updated_at", precision: 6, null: false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment