GeoRSS aggregator and Layar augmented reality server
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 

98 satır
2.4 KiB

  1. class LayersController < ApplicationController
  2. before_filter :require_login
  3. # GET /layers
  4. # GET /layers.json
  5. def index
  6. @layers = Layer.all
  7. respond_to do |format|
  8. format.html # index.html.erb
  9. format.json { render json: @layers }
  10. end
  11. end
  12. # GET /layers/1
  13. # GET /layers/1.json
  14. def show
  15. @layer = Layer.find(params[:id])
  16. @feed = Feed.new
  17. @feed.new_layer_id = @layer.id
  18. respond_to do |format|
  19. format.html # show.html.erb
  20. format.json { render json: @layer }
  21. end
  22. end
  23. # GET /layers/new
  24. # GET /layers/new.json
  25. def new
  26. @layer = Layer.new
  27. respond_to do |format|
  28. format.html # new.html.erb
  29. format.json { render json: @layer }
  30. end
  31. end
  32. # GET /layers/1/edit
  33. def edit
  34. @layer = Layer.find(params[:id])
  35. end
  36. # POST /layers
  37. # POST /layers.json
  38. def create
  39. @layer = Layer.new(params[:layer])
  40. respond_to do |format|
  41. if @layer.save
  42. format.html { redirect_to @layer, notice: 'Layer was successfully created.' }
  43. format.json { render json: @layer, status: :created, location: @layer }
  44. else
  45. format.html { render action: "new" }
  46. format.json { render json: @layer.errors, status: :unprocessable_entity }
  47. end
  48. end
  49. end
  50. # PUT /layers/1
  51. # PUT /layers/1.json
  52. def update
  53. @layer = Layer.find(params[:id])
  54. respond_to do |format|
  55. if @layer.update_attributes(params[:layer])
  56. format.html { redirect_to @layer, notice: 'Layer was successfully updated.' }
  57. format.json { head :no_content }
  58. else
  59. format.html { render action: "edit" }
  60. format.json { render json: @layer.errors, status: :unprocessable_entity }
  61. end
  62. end
  63. end
  64. # DELETE /layers/1
  65. # DELETE /layers/1.json
  66. def destroy
  67. @layer = Layer.find(params[:id])
  68. @layer.destroy
  69. respond_to do |format|
  70. format.html { redirect_to layers_url }
  71. format.json { head :no_content }
  72. end
  73. end
  74. # DELETE /layers/1/delete_feed
  75. # This only deletes the relation between the layer and the feed. The feed (and its posts) are retained.
  76. # Currently there's no way for the user to actually delete a feed completely.
  77. def delete_feed
  78. @layer = Layer.find(params[:id])
  79. @feed = Feed.find(params[:feed_id])
  80. @layer.feeds.delete(@feed)
  81. redirect_to @layer, notice: "Deleted feed #{@feed.title} from this layer"
  82. end
  83. end