network_controller.rb 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class NetworksController < ApplicationController
  3. before_filter :authentication_check
  4. # GET /networks
  5. # GET /networks.json
  6. def index
  7. @networks = Network.all
  8. respond_to do |format|
  9. format.html # index.html.erb
  10. format.json { render :json => @networks }
  11. end
  12. end
  13. # GET /networks/1
  14. # GET /networks/1.json
  15. def show
  16. @network = Network.find(params[:id])
  17. respond_to do |format|
  18. format.html # show.html.erb
  19. format.json { render :json => @network }
  20. end
  21. end
  22. # GET /networks/new
  23. # GET /networks/new.json
  24. def new
  25. @network = Network.new
  26. respond_to do |format|
  27. format.html # new.html.erb
  28. format.json { render :json => @network }
  29. end
  30. end
  31. # GET /networks/1/edit
  32. def edit
  33. @network = Network.find(params[:id])
  34. end
  35. # POST /networks
  36. # POST /networks.json
  37. def create
  38. @network = Network.new(params[:network])
  39. respond_to do |format|
  40. if @network.save
  41. format.html { redirect_to @network, :notice => 'Network was successfully created.' }
  42. format.json { render :json => @network, :status => :created }
  43. else
  44. format.html { render :action => "new" }
  45. format.json { render :json => @network.errors, :status => :unprocessable_entity }
  46. end
  47. end
  48. end
  49. # PUT /networks/1
  50. # PUT /networks/1.json
  51. def update
  52. @network = Network.find(params[:id])
  53. respond_to do |format|
  54. if @network.update_attributes(params[:network])
  55. format.html { redirect_to @network, :notice => 'Network was successfully updated.' }
  56. format.json { render :json => @network, :status => :ok }
  57. else
  58. format.html { render :action => "edit" }
  59. format.json { render :json => @network.errors, :status => :unprocessable_entity }
  60. end
  61. end
  62. end
  63. # DELETE /networks/1
  64. # DELETE /networks/1.json
  65. def destroy
  66. @network = Network.find(params[:id])
  67. @network.destroy
  68. respond_to do |format|
  69. format.html { redirect_to networks_url }
  70. format.json { head :ok }
  71. end
  72. end
  73. end