Skip to content

Instantly share code, notes, and snippets.

@yatmsu
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yatmsu/4002353c18fdfd386000 to your computer and use it in GitHub Desktop.
Save yatmsu/4002353c18fdfd386000 to your computer and use it in GitHub Desktop.
app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
private
# ActionMailerのdefault_url_optionsを変更する
def set_default_url_options; ActionMailer::Base.default_url_options[:host] = request.host_with_port end
end
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
before_action :set_default_url_options, only: [:create, :update]
# POST /users
# POST /users.json
def create
@user = User.new(user_params)
respond_to do |format|
if @user.register
format.html { redirect_to @user, notice: t('users.notices.create') }
format.json { render :show, status: :created, location: @user }
else
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
private
def set_user; @user = User.find params[:id] end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment