A fake auction house I made for a school project.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
the_auctionhouse/src/func.rb

25 lines
525 B

3 years ago
def get_random_subtitle
subtitles = File.readlines "misc/subtitles.txt"
subtitles.sample.chomp
end
def is_logged_in
session[:userid] != nil
end
def get_current_user
session[:userid] && User.find_by_id(session[:userid])
end
# Serve templates
def serve(template, locals={})
# Insert the error locals (if it exists)
locals[:error_msg] = session[:error_msg] or ""
session[:error_msg] = nil
locals[:session_user] = get_current_user unless !is_logged_in
# Serve the slim template
slim(template, locals: locals)
end