Guest User

Untitled

a guest
Feb 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. def index
  2. @clients = Client.find(:all, :visible_to => requester)
  3.  
  4. respond_to :last_modified_at => @clients.maximum(:updated_at) do |format|
  5. format.html { }
  6. format.any(:sskj1, :ssj) { }
  7. end
  8. end
  9.  
  10. def show
  11. @client = Client.find(params[:id], :visible_to => requester)
  12.  
  13. respond_to :last_modified_at => @client.updated_at do |format|
  14. format.html { }
  15. format.any(:sskj1, :ssj) { }
  16. end
  17. end
  18.  
  19. def new
  20. @client = Client.new
  21.  
  22. raise NotPermittedError unless requester.may_create? Client
  23.  
  24. respond_to :html
  25. end
  26.  
  27. def create
  28. munge_json_params!
  29.  
  30. @client = Client.new(params[:client])
  31.  
  32. raise NotPermittedError unless requester.may_create? @client
  33.  
  34. respond_to do |wants|
  35. if @client.save
  36. wants.html { redirect_to client_url(@client) }
  37. wants.any(:ssj, :sskj1) { head(:created, :location => client_url(@client)) }
  38. else
  39. wants.html { render :action => 'new' }
  40. wants.any(:ssj, :sskj1) { raise ActiveRecord::RecordInvalid, @client }
  41. end
  42. end
  43. end
  44.  
  45. def edit
  46. @client = client
  47.  
  48. raise NotPermittedError unless requester.may_modify? @client
  49.  
  50. respond_to :html, :last_modified_at => @client.updated_at
  51. end
  52.  
  53. def update
  54. @client = client
  55.  
  56. raise NotPermittedError unless requester.may_modify? @client
  57.  
  58. munge_json_params!
  59. @client.update_attributes!(params[:client])
  60. respond_to do |wants|
  61. wants.html { redirect_to client_url(@client) }
  62. wants.any(:sskj1, :ssj) { head(:ok) }
  63. end
  64. end
Add Comment
Please, Sign In to add comment