Guest User

Untitled

a guest
Feb 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. # SHOWS CONTROLLER - WORKS
  2. class Cp::ShowsController < Cp::BaseController
  3. layout "cp"
  4.  
  5. def index
  6. @shows = Show.find(:all)
  7. end
  8.  
  9. def new
  10. @show = Show.new
  11. @days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
  12. @hours = 00.upto(23)
  13. end
  14.  
  15. def create
  16. @show = Show.new(params[:cp_show])
  17. if @show.save
  18. flash[:notice] = "Show created, brosef."
  19. redirect_to cp_shows_path
  20. else
  21. render :action => 'index'
  22. end
  23. end
  24. end
  25.  
  26. # USERS CONTROLLER - DOESN'T WORK
  27. class Cp::UsersController < Cp::BaseController
  28. layout "cp"
  29.  
  30. def index
  31. @users = User.find(:all)
  32. end
  33.  
  34. def new
  35. @user = User.new
  36. @species = ['admin', 'management', 'dj']
  37. end
  38.  
  39. def create
  40. @user = User.new(params[:cp_user])
  41.  
  42. @user.dj_name = @user.name
  43. @user.status = 'inactive'
  44. @user.about = 'Fill me in.'
  45. @user.page_content = 'Listen to this show plzkthxbye.'
  46. @user.password = 'temp'
  47.  
  48. # Create Login: John Doe => jdoe
  49. @user.login = @user.name.downcase
  50. @user_names = @user.login.split(pattern = ' ')
  51. @user.login = @user_names[0].first
  52. @user.login += @user_names[1]
  53.  
  54. if @user.save
  55. flash[:notice] = "User created, brosef."
  56. redirect_to cp_users_path
  57. else
  58. render :action => 'new'
  59. end
  60. end
  61. end
Add Comment
Please, Sign In to add comment