Home>
Thing I want to do

I want to get the value with find_by (id) and output it with the instance method

Problem

find_by (id) is supposed to not exist
nil is back

code
Terminal
irb (main): 001: 0>upload = Upload.find_by (id: 5)
  Upload Load (0.4ms) SELECT "uploads". * FROM "uploads" WHERE "uploads". "Id" = $1 LIMIT $2 [["id", 5], ["LIMIT", 1]]
=>nil
schema.rb
create_table "users", force:: cascade do | t |
    t.string "name"
    t.string "email"
    t.string "string"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.string "password"
  end
end
model
class Upload
  • Answer # 1

    Probably because it doesn't exist
    At rails cUpload.idsPlease see at

Related articles

Trends