Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TrainingsController < ApplicationController
- before_filter :authenticate_user!, :only => [ :create, :destroy, :edit, :new, :update]
- add_breadcrumb I18n.t('breadcrumbs.home'), :root_path
- add_breadcrumb I18n.t('breadcrumbs.trainings'), :trainings_path
- # GET /trainings
- # GET /trainings.json
- def index
- @trainings = Training.last_updated.limit 20
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @trainings }
- format.atom { @trainings = Training.last_updated }
- format.rss { redirect_to events_url(:format => :atom), :status => :moved_permanently }
- end
- end
- # GET /trainings/1
- # GET /trainings/1.json
- def show
- @training = Training.find(params[:id])
- add_breadcrumb @training.name, :training_path
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @training }
- end
- end
- # GET /trainings/new
- # GET /trainings/new.json
- def new
- @training = Training.new
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @training }
- end
- end
- # GET /trainings/1/edit
- def edit
- @training = Training.find(params[:id])
- end
- # POST /trainings
- # POST /trainings.json
- def create
- @training = Training.new(params[:training])
- respond_to do |format|
- if @training.save
- format.html { redirect_to @training, notice: 'Training was successfully created.' }
- format.json { render json: @training, status: :created, location: @training }
- else
- format.html { render action: "new" }
- format.json { render json: @training.errors, status: :unprocessable_entity }
- end
- end
- end
- # PUT /trainings/1
- # PUT /trainings/1.json
- def update
- @training = Training.find(params[:id])
- respond_to do |format|
- if @training.update_attributes(params[:training])
- format.html { redirect_to @training, notice: 'Training was successfully updated.' }
- format.json { head :no_content }
- else
- format.html { render action: "edit" }
- format.json { render json: @training.errors, status: :unprocessable_entity }
- end
- end
- end
- # DELETE /trainings/1
- # DELETE /trainings/1.json
- def destroy
- @training = Training.find(params[:id])
- @training.destroy
- respond_to do |format|
- format.html { redirect_to trainings_url }
- format.json { head :no_content }
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement