How railsapps/learn-rails works
1. This is a Rails 5.1 “small business website” app: mostly server-rendered HTML, with two interactive business flows layered on top of static pages—mailing-list signup and contact-email submission.
2. The main request boundary is config/routes.rb into three areas: a visitor/home flow (VisitorsController), a contact form flow (ContactsController), and static content served through high_voltage for pages like About. The app is intentionally simple and does not expose an API.
3. The presentation layer is conventional Rails MVC views under app/views, with a shared layout in app/views/layouts/application.html.erb, navigation/message partials, and page-specific templates for the home/sign-up page, contact form, and About page. Styling is built with Foundation (foundation-rails) via the asset pipeline.
4. The home page signup flow centers on Visitor in app/models/visitor.rb and VisitorsController. The model exists primarily for validation; when a valid email is submitted, the app calls MailChimp through the gibbon gem using API credentials from secrets/environment configuration.
5. The contact form flow uses Contact in app/models/contact.rb plus ContactsController. Submitted contact data is validated, then handed off to UserMailer (app/mailers/user_mailer.rb) to send an email to the site owner. This is an outbound email boundary rather than persistent storage.
6. Email delivery is configured around Action Mailer and the user_mailer view templates. In development/production, SMTP credentials are expected to come from SendGrid-related environment variables, while the destination owner address is also injected through secrets.
7. There is no real application database domain here. Although Rails ActiveRecord is present and SQLite is included, the README makes clear user-submitted data is not meant to be stored locally; ActiveRecord is mainly used for form validation and Rails conventions, not as a business data store.
8. Static content is intentionally separated from dynamic flows. The About page comes from high_voltage, which lets Rails render fixed content while still using the shared site layout, navigation, and footer.
9. The front-end assets are managed through Rails’ asset pipeline (app/assets). JavaScript and CSS entrypoints are present for the app bundle, and the layout partials provide global UI elements such as navigation and flash messages.
10. Configuration is environment-driven and centralized in config/secrets.yml: SendGrid credentials, MailChimp API key/list ID, site domain, owner email, and secret_key_base. That makes external integrations and deployment-sensitive settings the main operational boundary.
11. Runtime and deployment are standard Rails: Puma serves the app, and the README describes Heroku deployment with env vars mapped into the app’s secrets. Action Cable, jobs, and other Rails subsystems are present mostly as framework scaffolding, not as core architecture.
12. Test coverage reflects the architecture: an integration test for the home page flow, model tests for Visitor, and mailer tests/previews for UserMailer. That mirrors the two important business paths—newsletter signup and contact email—plus the static home page.
Main entry points: application.html.erb App layout · visitors_controller.rb Visitors · contacts_controller.rb Contacts · routes.rb Routes
Components 22
Presentation
Shared layout and server-rendered pages
- App layout · Shared site chrome and page composition
app/views/layouts/application.html.erb - Navigation · Global menu links
app/views/layouts/_navigation.html.erb - Messages · Flash and status messaging
app/views/layouts/_messages.html.erb - Home page · Signup landing page
app/views/visitors/new.html.erb - Contact form · Contact submission page
app/views/contacts/new.html.erb - About page · High Voltage served content
app/views/pages/about.html.erb
Business flows
Visitor signup and contact submission
- Visitors · Handles homepage and mailing-list signup
app/controllers/visitors_controller.rb - Visitor · Validates signup email before mailing-list submit
app/models/visitor.rb - Contacts · Handles contact form submission
app/controllers/contacts_controller.rb - Contact · Validates contact form input
app/models/contact.rb
External integrations
Mailing list and outbound email boundaries
- User mailer · Builds outbound contact email
app/mailers/user_mailer.rb - Mail views · HTML and text email bodies
app/views/user_mailer/contact_email.html.erb - MailChimp · Newsletter signup destination via Gibbon
- SMTP/SendGrid · Outbound email transport for mailer delivery
Configuration
Routing, secrets, and runtime setup
Tests
Coverage for the main user-facing paths
- Home test · Covers the homepage signup flow
test/integration/home_page_test.rb - Visitor test · Covers visitor validation
test/models/visitor_test.rb - Mailer test · Covers contact email delivery behavior
test/mailers/user_mailer_test.rb - Mailer preview · Preview for contact email templates
test/mailers/previews/user_mailer_preview.rb
Connections 24
- Routes → Visitors: home/signup · Routes dispatch the visitor-facing homepage flow
- Routes → Contacts: contact · Routes dispatch the contact form flow
- Routes → About page: static page · Routes expose static content through High Voltage
- Visitors → Visitor: validate · Signup input is validated before external submission
- Visitors → MailChimp: subscribe · Valid emails are sent to MailChimp through Gibbon
- Visitor → Secrets: credentials · MailChimp API settings are sourced from secrets or environment
- Contacts → Contact: validate · Contact data is validated before email handoff
- Contacts → User mailer: deliver · Valid contact submissions are passed to the mailer
- User mailer → Mail views: render · Mailer composes HTML and text email bodies from templates
- User mailer → SMTP/SendGrid: send · Action Mailer delivers through SMTP/SendGrid
- SMTP/SendGrid → Secrets: auth · SMTP credentials and owner address come from secrets or env
- App layout → Navigation: includes · Shared layout renders navigation partial
- App layout → Messages: includes · Shared layout renders flash/message partial
- App layout → Assets: loads assets · Layout pulls in bundled styles and scripts
- Visitors → Home page: renders · Visitor flow renders the homepage template
- Contacts → Contact form: renders · Contact flow renders the form template
- About page → App layout: uses layout · Static content is wrapped by the shared site chrome
- Home page → App layout: uses layout · Homepage is served within the shared layout
- Contact form → App layout: uses layout · Contact page is served within the shared layout
- Home test → Visitors: covers · Integration test exercises the homepage flow
- Visitor test → Visitor: covers · Model test exercises signup validation
- Mailer test → User mailer: covers · Mailer test exercises outbound contact email
- Mailer preview → Mail views: covers · Preview exercises the email templates
- Puma → Routes: serves · Puma hosts the Rails application entry point