Sha256: 1821fe7b3b0ae477cf98b27ad418b7755cbdc9a9fb2f21bc603ed2b8113e46d1
Contents?: true
Size: 2 KB
Versions: 1
Compression:
Stored size: 2 KB
Contents
class AlunosController < ApplicationController # GET /alunos # GET /alunos.json def index @alunos = Aluno.all respond_to do |format| format.html # index.html.erb format.json { render json: @alunos } end end # GET /alunos/1 # GET /alunos/1.json def show @aluno = Aluno.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @aluno } end end # GET /alunos/new # GET /alunos/new.json def new @aluno = Aluno.new respond_to do |format| format.html # new.html.erb format.json { render json: @aluno } end end # GET /alunos/1/edit def edit @aluno = Aluno.find(params[:id]) end # POST /alunos # POST /alunos.json def create @aluno = Aluno.new(aluno_params) respond_to do |format| if @aluno.save @alunos = Aluno.find(:all, :select => "id, nome", :order => "nome") format.html { redirect_to @aluno, notice: 'Aluno was successfully created.' } format.json { render json: @alunos, status: :created } else format.html { render action: "new" } format.json { render json: @aluno.errors, status: :unprocessable_entity } end end end # PUT /alunos/1 # PUT /alunos/1.json def update @aluno = Aluno.find(params[:id]) respond_to do |format| if @aluno.update_attributes(aluno_params) format.html { redirect_to @aluno, notice: 'Aluno was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @aluno.errors, status: :unprocessable_entity } end end end # DELETE /alunos/1 # DELETE /alunos/1.json def destroy @aluno = Aluno.find(params[:id]) @aluno.destroy respond_to do |format| format.html { redirect_to alunos_path } format.json { head :no_content } end end def aluno_params params.require(:aluno).permit(:nome, :cpf, :telefone, :email) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omniauth-sabia-1.0.1 | app/controllers/alunos_controller.rb |