using rake db:migrate with sinatra and activerecord (not rails)
First of all, try to strip the leading and trailing whitespaces after you take the input email, like this:
admin_email = gets.chomp.stripputs "admin_email: #{admin_email.inspect}"
Then, try your script again. It should work.
To explain what's going on here, your query:
find_admin = Admin.find_by(email:admin_email)
this can't find an admin record with the provided email. So, it's a nil
object and when you call: find_admin.email
i.e. nil.email
then you get the error:
undefined method `email' for nil:NilClass (NoMethodError)
You need to make sure you have an admin with the given email. To do that, you can create one first, in your rails console, do this:
Admin.create!(email: 'testadmin@test.com')
Then, try to find the admin like above by giving testadmin@test.com
as input.
It should work if the admin record with the given email is present in the database.