Last active
August 29, 2015 14:15
-
-
Save yatmsu/4002353c18fdfd386000 to your computer and use it in GitHub Desktop.
app/controllers/application_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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