Created
December 2, 2013 17:08
-
-
Save mamhoff/7752804 to your computer and use it in GitHub Desktop.
code duplication with multiple user models
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 AdminsController < ApplicationController | |
def new | |
@admin = Admin.new | |
end | |
def show | |
@admin = Admin.find(params[:id]) | |
end | |
def create | |
@admin = Admin.new(admin_params) | |
if @admin.save | |
flash[:success] = "Welcome to the Solar Explorer!" | |
redirect_to @admin | |
else | |
render 'new' | |
end | |
end | |
private | |
def admin_params | |
params.require(:admin).permit(:name, :email, :password, | |
:password_confirmation) | |
end | |
end |
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 GuidesController < ApplicationController | |
def new | |
@guide = Guide.new | |
end | |
def show | |
@guide = Guide.find(params[:id]) | |
end | |
def create | |
@guide = Guide.new(guide_params) | |
if @guide.save | |
flash[:success] = "Welcome to the Solar Explorer!" | |
redirect_to @guide | |
else | |
render 'new' | |
end | |
end | |
private | |
def guide_params | |
params.require(:guide).permit(:name, :email, :password, | |
:password_confirmation) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment