Skip to content

Instantly share code, notes, and snippets.

View HopperMCS's full-sized avatar

G. F. Hopper HopperMCS

View GitHub Profile
def start
API.api_public_key
puts "Welcome to the News CLI!"
menu
@input = "query"
while @input != "exit" && @input != "quit" && @input != "q"
Article.clear
article_search
article_navigator
def article_search
@input = gets.chomp
Article.search(@input) unless @input == "exit"
Article.all.each.with_index(1) do |art, index|
puts "#{index}. #{art.title}"
end
end
def article_navigator
while @input != "exit" && @input != "query"
puts "Choose a number"
@input = gets.chomp
index = @input.to_i - 1
if index > 9
puts "Wrong input, try again"
else
break if index < 0
selected_article = Article.all[index]
class User < ActiveRecord::Base
has_secure_password
has_many :books
has_many :book_reports
validates :username, presence: true, uniqueness: true
end
require 'pry'
class AuthenticationsController < ApplicationController
get '/signup' do
@user = User.new
already_authenticated
erb :'./authentication/signup'
end
post "/signup" do
# Create a new ActiveRecord object using params submitted by Sinatra