All code is available in example app - https://github.com/maxivak/webpacker-rails-example-app
All code is available in example app - https://github.com/maxivak/webpacker-rails-example-app
Run rails new --help
to view all of the options you can pass to rails new
:
$ bin/rails new --help
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /Users/eliot/.rbenv/versions/2.2.0/bin/ruby
FROM ruby:2.4 | |
## In case of postgresql for heroku: | |
# RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" >> /etc/apt/sources.list.d/postgeresql.list \ | |
# && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ | |
# && apt-get update \ | |
# && apt-get update \ | |
# && apt-get install -y --no-install-recommends \ | |
# postgresql-client-9.6 pv ack-grep ccze unp htop vim \ | |
# && rm -rf /var/lib/apt/lists/* \ |
module Support | |
extend ActiveSupport::Concern | |
included do | |
support_path = "app/support/#{name.underscore}/" | |
actions_path = File.join('.', "#{support_path}actions/*.rb") | |
queries_path = File.join('.', "#{support_path}queries/*.rb") | |
events_path = File.join('.', "#{support_path}events/*.rb") | |
Dir[actions_path, queries_path, events_path].each do |f| |
unique_email_validator = validators_on(:email).find { |v| | |
v.is_a?(ActiveRecord::Validations::UniquenessValidator) | |
} | |
def unique_email_validator.validate(*users) | |
return false if users.map(&:chatbox).all? | |
return false unless app_users?(users.collect(&:email)) | |
super |
ARCHFLAGS="-arch x86_64" bundle install --path vendor/bundle |
If you're writing web applications with Ruby there comes a time when you might need something a lot simpler, or even faster, than Ruby on Rails or the Sinatra micro-framework. Enter Rack.
Rack describes itself as follows:
Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.
Before Rack came along Ruby web frameworks all implemented their own interfaces, which made it incredibly difficult to write web servers for them, or to share code between two different frameworks. Now almost all Ruby web frameworks implement Rack, including Rails and Sinatra, meaning that these applications can now behave in a similar fashion to one another.
At it's core Rack provides a great set of tools to allow you to build the most simple web application or interface you can. Rack applications can be written in a single line of code. But we're getting ahead of ourselves a bit.
HTTP status code symbols for Rails | |
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
Status Code Symbol | |
1xx Informational | |
100 :continue | |
101 :switching_protocols | |
102 :processing |
SELECT pg_terminate_backend(pid) FROM pg_stat_activity | |
WHERE pid <> pg_backend_pid() AND datname = current_database(); |