Skip to content

Instantly share code, notes, and snippets.

@mamhoff
Created December 2, 2013 17:08
Show Gist options
  • Save mamhoff/7752804 to your computer and use it in GitHub Desktop.
Save mamhoff/7752804 to your computer and use it in GitHub Desktop.
code duplication with multiple user models
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
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