Commit 2f074fa9 authored by Mateus Rambo Strey's avatar Mateus Rambo Strey

until step 5

parent 1c03f93f
class ApplicationJob < ActiveJob::Base
end
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end
class Application < ActiveRecord::Base
class Application < ApplicationRecord
belongs_to :user
validates :domain, presence: true, uniqueness: true
......
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
......@@ -10,7 +10,7 @@
# updated_at :datetime not null
#
class Bookmark < ActiveRecord::Base
class Bookmark < ApplicationRecord
# Example of Trackable:
# *current_user* create bookmark *bookmarkable*
include Trackable
......
......@@ -13,7 +13,7 @@
# image_updated_at :datetime
#
class Carousel < ActiveRecord::Base
class Carousel < ApplicationRecord
has_attached_file :image, styles: {
larger: "600x600>",
thumbnail: "100x100>"
......
......@@ -22,7 +22,7 @@
# thumbnail_updated_at :datetime
#
class Collection < ActiveRecord::Base
class Collection < ApplicationRecord
include Reviewable
include Sociable
include Followable
......
......@@ -11,7 +11,7 @@
# updated_at :datetime not null
#
class CollectionItem < ActiveRecord::Base
class CollectionItem < ApplicationRecord
# *current_user* add item *collectionable* to *collection*
include Trackable
......
......@@ -12,7 +12,7 @@
# updated_at :datetime not null
#
class Complaint < ActiveRecord::Base
class Complaint < ApplicationRecord
# *current_user* create complaint about *complaint_reason* for *complaintable*
include Trackable
......
......@@ -8,7 +8,7 @@
# updated_at :datetime not null
#
class ComplaintReason < ActiveRecord::Base
class ComplaintReason < ApplicationRecord
# *current_user* create complaint reason
# Only admins can create complaint reasons
include Trackable
......
......@@ -10,7 +10,7 @@
# updated_at :datetime not null
#
class Download < ActiveRecord::Base
class Download < ApplicationRecord
# *current_user* download *downloadable*
include Trackable
......
......@@ -10,7 +10,7 @@
# updated_at :datetime not null
#
class Follow < ActiveRecord::Base
class Follow < ApplicationRecord
# *current_user* follows *followable*
include Trackable
......
......@@ -12,7 +12,7 @@
# updated_at :datetime not null
#
class Institution < ActiveRecord::Base
class Institution < ApplicationRecord
include Tagger
# *current_user* add member for instituion *name*
......
......@@ -9,7 +9,7 @@
# code :string
#
class Language < ActiveRecord::Base
class Language < ApplicationRecord
has_many :learning_objects
validates_uniqueness_of :code
......
......@@ -30,7 +30,7 @@
# attachment_id :integer
#
class LearningObject < ActiveRecord::Base
class LearningObject < ApplicationRecord
include Metadatable
include Reviewable
include Sociable
......
......@@ -22,7 +22,7 @@
# cache_link :string
#
class LearningObject::Attachment < ActiveRecord::Base
class LearningObject::Attachment < ApplicationRecord
include ::Thumbnailable
belongs_to :learning_object
scope :unknown_mime_type, ->() { where(format: 'Unknown') }
......
class License < ActiveRecord::Base
class License < ApplicationRecord
validates :name, presence: true
end
......@@ -10,7 +10,7 @@
# updated_at :datetime not null
#
class Like < ActiveRecord::Base
class Like < ApplicationRecord
# *current_user* likes *likeable*
# *current_user* unlikes *likeable*
include Trackable
......
......@@ -7,6 +7,6 @@
# mime_type :string
#
class MimeType < ActiveRecord::Base
class MimeType < ApplicationRecord
has_and_belongs_to_many :object_types
end
class ObjectType < ActiveRecord::Base
class ObjectType < ApplicationRecord
has_many :learning_objects
has_and_belongs_to_many :mime_types
......
......@@ -8,7 +8,7 @@
# review_id :integer
# created_at :datetime not null
# updated_at :datetime not null
class Rate < ActiveRecord::Base
class Rate < ApplicationRecord
# *current_user* rate a review *review*
include Trackable
......
......@@ -9,7 +9,7 @@
# description :string
#
class Rating < ActiveRecord::Base
class Rating < ApplicationRecord
has_many :review_ratings
has_many :reviews, through: :review_ratings
end
......@@ -15,7 +15,7 @@
# rates_count :integer default("0")
#
class Review < ActiveRecord::Base
class Review < ApplicationRecord
# *current_user* review *reviewable*
include Trackable
......
......@@ -10,7 +10,7 @@
# updated_at :datetime not null
#
class ReviewRating < ActiveRecord::Base
class ReviewRating < ApplicationRecord
belongs_to :review
belongs_to :rating
......
......@@ -9,7 +9,7 @@
# updated_at :datetime not null
#
class Role < ActiveRecord::Base
class Role < ApplicationRecord
has_and_belongs_to_many :users
validates_presence_of :name
......
......@@ -12,7 +12,7 @@
# score_type :string default("{}"), is an Array
#
class Score < ActiveRecord::Base
class Score < ApplicationRecord
has_many :score_user_categories
has_many :user_categories, through: :score_user_categories
......
......@@ -10,7 +10,7 @@
# updated_at :datetime not null
#
class ScoreUserCategory < ActiveRecord::Base
class ScoreUserCategory < ApplicationRecord
belongs_to :score
belongs_to :user_category
......
......@@ -10,7 +10,7 @@
# updated_at :datetime not null
#
class Share < ActiveRecord::Base
class Share < ApplicationRecord
# *current_user* shares *shareable*
include Trackable
......
class Tag < ActiveRecord::Base
class Tag < ApplicationRecord
has_many :taggings
validates_presence_of :name
end
class Tagging < ActiveRecord::Base
class Tagging < ApplicationRecord
# *current_user* tag *taggable* with *tag*
include Trackable
......
......@@ -33,7 +33,7 @@
# follows_count :integer default("0")
#
class User < ActiveRecord::Base
class User < ApplicationRecord
include Followable
include Reputationable
include Tagger
......
......@@ -9,7 +9,7 @@
# updated_at :datetime not null
#
class UserCategory < ActiveRecord::Base
class UserCategory < ApplicationRecord
has_many :score_user_categories
has_many :scores, through: :score_user_categories
......
......@@ -10,7 +10,7 @@
# updated_at :datetime not null
#
class View < ActiveRecord::Base
class View < ApplicationRecord
# *current_user* views *viewable*
include Trackable
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>/* Email styles need to be inline */</style>
</head>
<body><%= yield %></body>
</html>
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
# Add necessary setup steps to this file.
puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install --jobs $(nproc)"
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "\n== Checks database config file =="
unless File.exist?("config/database.yml")
puts "\n You need create config/database.yml. Please follow our README"
exit
end
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing databases, importing data and setup PortalMEC =="
system "bundle exec rake portalmec:setup"
puts "\n== Preparing database =="
system! 'bundle exec rake portalmec:setup'
puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
system! 'bin/rails restart'
end
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "\n== Updating database =="
system! 'bin/rails db:migrate'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
require File.expand_path('../boot', __FILE__)
require_relative 'boot'
# require 'rails/all'
require 'rails'
require 'active_model/railtie'
# require 'active_job/railtie'
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'action_view/railtie'
# require 'action_cable/engine'
# require 'sprockets/railtie'
require 'rails/test_unit/railtie'
require 'rack/redis_throttle'
......
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
development:
adapter: async
test:
adapter: async
production:
adapter: redis
url: redis://localhost:6379/1
......@@ -15,7 +15,7 @@ test:
database: portalmec_test
username: portalmec
password: 123mudar
host: postgres
# host: postgres
production:
<<: *defaults
......
# Load the Rails application.
require File.expand_path('../application', __FILE__)
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
......@@ -21,32 +21,55 @@ Rails.application.configure do
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# config.assets.digest = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
......
......@@ -14,33 +14,23 @@ Rails.application.configure do
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
......@@ -49,32 +39,19 @@ Rails.application.configure do
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
config.log_tags = [ :request_id ]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# memcached server specified in ENV["MEMCACHE_SERVERS"]
config.cache_store = :dalli_store, nil, { :namespace => 'portalmec', :expires_in => 1.day, :compress => true, :pool_size => 5 }
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "portalmec_#{Rails.env}"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = { host: ENV['ACTION_MAILER_HOST'] }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: ENV['SMTP_ADDRESS'],
port: ENV['SMTP_PORT'],
openssl_verify_mode: 'none',
domain: ENV['ACTION_MAILER_HOST']
}
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
......@@ -86,6 +63,31 @@ Rails.application.configure do
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
config.cache_store = :dalli_store, nil, { :namespace => 'portalmec', :expires_in => 1.day, :compress => true, :pool_size => 5 }
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = { host: ENV['ACTION_MAILER_HOST'] }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: ENV['SMTP_ADDRESS'],
port: ENV['SMTP_PORT'],
openssl_verify_mode: 'none',
domain: ENV['ACTION_MAILER_HOST']
}
end
......@@ -14,7 +14,10 @@ Rails.application.configure do
# Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=3600'
}
# Show full error reports and disable caching.
config.consider_all_requests_local = true
......
# Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
# Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :marshal
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.0 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Rails 5.0 release notes for more info on each option.
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
# Previous versions had false.
ActiveSupport.to_time_preserves_timezone = false
# Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = false
# Do not halt callback chains when a callback returns false. Previous versions had true.
ActiveSupport.halt_callback_chains_on_return_false = true
......@@ -5,10 +5,10 @@
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# self.include_root_in_json = true
# end
# Change to match your CPU core count
workers 2
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
#
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
threads threads_count, threads_count
# Min and Max threads per worker
threads 1, 6
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
#
port ENV.fetch('PORT') { 3000 }
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch('RAILS_ENV') { 'development' }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
workers ENV.fetch('WEB_CONCURRENCY') { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#