Advertisement
rodrigofbm

controller.rb

Apr 7th, 2017
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.59 KB | None | 0 0
  1. class SegredosController < ApplicationController
  2.  
  3.     def index
  4.         @segredos = Segredo.all
  5.        
  6.         respond_with(@segredos)
  7.        
  8.     end
  9.    
  10.     def show
  11.         @segredo = Segredo.find(params[:id])
  12.         respond_with(@segredo)
  13.     end
  14.  
  15.     def new
  16.         @segredo = Segredo.new
  17.          respond_with(@segredo)
  18.        
  19.     end
  20.  
  21.     def create
  22.         @segredo = Segredo.new(segredo_params)
  23.        
  24.           if @segredo.save
  25.             respond_with(@segredo, :location => segredos_url)
  26.           else
  27.             render :new
  28.           end
  29.    
  30.     end
  31.    
  32.  
  33.     private
  34.         def segredo_params
  35.             params.require(:segredo).permit(:secret)
  36.            
  37.         end
  38.  
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement