Guest User

Untitled

a guest
Dec 11th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. class ThemesController < ApplicationController
  2. def index
  3. @themes = Theme.all
  4. end
  5.  
  6. def show
  7. @theme = Theme.find(params[:id])
  8. end
  9.  
  10. def new
  11. @theme = Theme.new
  12. end
  13.  
  14. def create
  15. @theme = Theme.new(params[:theme])
  16. if @theme.save
  17. redirect_to @theme, :notice => "Successfully created theme."
  18. else
  19. render :action => 'new'
  20. end
  21. end
  22.  
  23. def edit
  24. @theme = Theme.find(params[:id])
  25. end
  26.  
  27. def update
  28. @theme = Theme.find(params[:id])
  29. if @theme.update_attributes(params[:theme])
  30. redirect_to @theme, :notice => "Successfully updated theme #{@theme.name}."
  31. else
  32. render :action => 'edit'
  33. end
  34. end
  35.  
  36. def destroy
  37. @theme = Theme.find(params[:id])
  38. @theme.destroy
  39. redirect_to themes_url, :notice => "Successfully destroyed theme."
  40. end
  41. end
Add Comment
Please, Sign In to add comment