Skip to content

Instantly share code, notes, and snippets.

@owade
Created December 27, 2014 20:25
Show Gist options
  • Save owade/d48bac8093d9aa734da6 to your computer and use it in GitHub Desktop.
Save owade/d48bac8093d9aa734da6 to your computer and use it in GitHub Desktop.
class ZombiesController < ApplicationController
def index
if params[:name]
@zombie=Zombie.where(:name => params[:name]).first
@[email protected]
else
@z=Zombie.all
end
end
def show
#@z=Zombie.find(params[:id])
#@@zom=Zombie.where(:name => 'Joel').first
#@b=@@zom.id
###################################################################################################
if params[:name]
@zombie=Zombie.where(:name=> params[:name]).first
@z=@zombie
else
@z=Zombie.find(params[:id])
end
#respond_to do |format|
# format.html #show.html.erb
# format.json{ render json: @tweet}
# format.xml {render xml: @tweet}
#end
###################################################################################################
#@z=Zombie.find(params[:id])
end
def edit
@z=Zombie.find(params[:id])
end
def update
@z=Zombie.find(params[:id])
if @z.update_attributes(admin_user_params)
flash[:success]='INFO WAS UPDATED'
redirect_to :controller => 'sessions' ,:action => 'new'
else
render('edit')
end
end
def delete
end
def create
@z = Zombie.new(admin_user_params)
respond_to do |format|
if @z.save
format.html { redirect_to @z, notice: 'Zombie was successfully created.' }
format.json { render :show, status: :created, location: @z }
else
format.html { render :new }
format.json { render json: @z.errors, status: :unprocessable_entity }
end
end
end
def new
@z=Zombie.new
end
private
def admin_user_params
params.require(:zombie).permit(:name, :graveyard,:email, :password,:avatar, :password_confirmation)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment