diff --git a/Gemfile b/Gemfile index 6be4ccc8..890425e7 100644 --- a/Gemfile +++ b/Gemfile @@ -163,6 +163,8 @@ group :development do gem 'sqlite3' # Use letter_opener to open mails in development gem 'letter_opener' + # Use letter_opener_web to open mails in browser (e.g. necessary for Vagrant) + gem 'letter_opener_web' # mina is a blazing fast deployment system gem 'mina' gem 'web-console', '~> 2.0' diff --git a/Gemfile.lock b/Gemfile.lock index 436ed447..a958697c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -211,6 +211,10 @@ GEM addressable (~> 2.3) letter_opener (1.2.0) launchy (~> 2.2) + letter_opener_web (1.3.0) + actionmailer (>= 3.2) + letter_opener (~> 1.0) + railties (>= 3.2) listen (2.7.2) celluloid (>= 0.15.2) celluloid-io (>= 0.15.0) @@ -518,6 +522,7 @@ DEPENDENCIES jquery-datatables-rails (~> 2.2.1) jquery-rails letter_opener + letter_opener_web mina money-rails mysql2 diff --git a/INSTALL.md b/INSTALL.md index a44ac3a6..4ee49ab0 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -47,6 +47,11 @@ You can access the app [localhost:3000](http://localhost:3000). Whatever you cha vagrant ssh ``` +**Note**: We use [letter_opener](https://github.com/ryanb/letter_opener) in development environment. +However, letter_opener uses launchy to present the emails in your browser which doesn't work in combination with Vagrant. +Therefore we use [letter_open_web](https://github.com/fgrehm/letter_opener_web). +You can check out your mails by visiting [localhost:3000/letter_opener](http://localhost:3000/letter_opener) if you use Vagrant. + ### Run OSEM in production We recommend to run OSEM in production with [mod_passenger](https://www.phusionpassenger.com/download/#open_source) and the [apache web-server](https://www.apache.org/). There are tons of guides on how to deploy rails apps on various diff --git a/config/environments/development.rb b/config/environments/development.rb index e1610a27..ab207493 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -4,6 +4,9 @@ Osem::Application.configure do # Use letter_opener config.action_mailer.delivery_method = :letter_opener + # Use letter_opener_web for Vagrant (launchy won't work) + config.action_mailer.delivery_method = ENV['USER'] == 'vagrant' ? :letter_opener_web : :letter_opener + # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. diff --git a/config/routes.rb b/config/routes.rb index 1df57cbe..40b45a80 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,6 +10,11 @@ Osem::Application.routes.draw do path: 'accounts' end + # Use letter_opener_web to open mails in browser (e.g. necessary for Vagrant) + if Rails.env.development? + mount LetterOpenerWeb::Engine, at: "/letter_opener" + end + resources :users, except: [:new, :index, :create, :destroy] namespace :admin do