Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TutorialsController < ApplicationController
- # GET /tutorials
- # GET /tutorials.xml
- before_filter :authenticate
- def index
- @tutorials = Tutorial.all
- respond_to do |format|
- format.html # index.html.erb
- format.xml { render :xml => @tutorials }
- end
- end
- # GET /tutorials/1
- # GET /tutorials/1.xml
- def show
- @tutorial = Tutorial.find_by_name(params[:id])
- respond_to do |format|
- format.html # show.html.erb
- format.xml { render :xml => @tutorial }
- end
- end
- # GET /tutorials/new
- # GET /tutorials/new.xml
- def new
- @tutorial = Tutorial.new
- respond_to do |format|
- format.html # new.html.erb
- format.xml { render :xml => @tutorial }
- end
- end
- # GET /tutorials/1/edit
- def edit
- @tutorial = Tutorial.find_by_name(params[:id])
- end
- # POST /tutorials
- # POST /tutorials.xml
- def create
- @tutorial = Tutorial.new(params[:tutorial])
- respond_to do |format|
- if @tutorial.save
- flash[:notice] = 'Tutorial was successfully created.'
- format.html { redirect_to(@tutorial) }
- format.xml { render :xml => @tutorial, :status => :created, :location => @tutorial }
- else
- format.html { render :action => "new" }
- format.xml { render :xml => @tutorial.errors, :status => :unprocessable_entity }
- end
- end
- end
- # PUT /tutorials/1
- # PUT /tutorials/1.xml
- def update
- @tutorial = Tutorial.find_by_name(params[:id])
- respond_to do |format|
- if @tutorial.update_attributes(params[:tutorial])
- flash[:notice] = 'Tutorial was successfully updated.'
- format.html { redirect_to(@tutorial) }
- format.xml { head :ok }
- else
- format.html { render :action => "edit" }
- format.xml { render :xml => @tutorial.errors, :status => :unprocessable_entity }
- end
- end
- end
- # DELETE /tutorials/1
- # DELETE /tutorials/1.xml
- def destroy
- @tutorial = Tutorial.find_by_name(params[:id])
- @tutorial.destroy
- respond_to do |format|
- format.html { redirect_to(tutorials_url) }
- format.xml { head :ok }
- end
- protected
- def authenticate
- authenticate_or_request_with_http_basic do |username, password|
- username == "admin" && password == "m6219123"
- <% end %>
- end
Add Comment
Please, Sign In to add comment