Skip to content

Commit

Permalink
Add example app for Rails 6
Browse files Browse the repository at this point in the history
  • Loading branch information
fphilipe committed Oct 15, 2022
1 parent dc77061 commit 6ae0861
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/rails6/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
5 changes: 5 additions & 0 deletions examples/rails6/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem 'rails', '~> 6.1.7'
gem 'webrick' if RUBY_VERSION >= '3'
gem 'premailer-rails', path: '../..'
10 changes: 10 additions & 0 deletions examples/rails6/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Example Rails App

To run this app, run:

```shell
bundle
bundle exec rails s
```

Then point your browser at [http://localhost:3000/](http://localhost:3000/).
6 changes: 6 additions & 0 deletions examples/rails6/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'

Rails.application.load_tasks
1 change: 1 addition & 0 deletions examples/rails6/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//= link email.css
32 changes: 32 additions & 0 deletions examples/rails6/app/assets/stylesheets/email.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
body {
background: #efefef;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

p {
line-height: 1.4;
}

.wrap {
max-width: 40em;
margin: 0 auto;
padding: 1em;
background: white;
}

.greeting {
text-align: center;
font-weight: bold;
font-size: 110%;
}

.footer {
font-size: 90%;
color: #666;
}

a {
color: green;
text-decoration: none;
border-bottom: 2px solid green;
}
7 changes: 7 additions & 0 deletions examples/rails6/app/mailers/example_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ExampleMailer < ActionMailer::Base
default from: "[email protected]"

def test_message
mail to: '[email protected]', subject: 'Test Message'
end
end
18 changes: 18 additions & 0 deletions examples/rails6/app/views/example_mailer/test_message.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<%= stylesheet_link_tag :email %>
</head>
<body>
<div class='wrap'>
<p class='greeting'>Hi, John Doe</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<div class='footer'>
To unsubscribe, <a href='http://www.google.com/'>click here</a>.
</div>
</div>
</body>
</html>
4 changes: 4 additions & 0 deletions examples/rails6/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
6 changes: 6 additions & 0 deletions examples/rails6/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is used by Rack-based servers to start the application.

require_relative 'config/environment'

run Rails.application
Rails.application.load_server
15 changes: 15 additions & 0 deletions examples/rails6/config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require_relative 'boot'

require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'sprockets/railtie'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Example
class Application < Rails::Application
config.load_defaults 6.1
end
end
3 changes: 3 additions & 0 deletions examples/rails6/config/boot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
5 changes: 5 additions & 0 deletions examples/rails6/config/environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Load the Rails application.
require_relative 'application'

# Initialize the Rails application.
Rails.application.initialize!
9 changes: 9 additions & 0 deletions examples/rails6/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Rails.application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.assets.debug = true
config.assets.digest = true
config.assets.raise_runtime_errors = true
end
9 changes: 9 additions & 0 deletions examples/rails6/config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.assets.compile = false
config.assets.digest = true
config.log_level = :info
end
3 changes: 3 additions & 0 deletions examples/rails6/config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Rails.application.routes.draw do
root to: redirect('rails/mailers/example_mailer/test_message')
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ExampleMailerPreview < ActionMailer::Preview
def test_message
ExampleMailer.test_message
end
end

0 comments on commit 6ae0861

Please sign in to comment.