Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AdsController < ApplicationController
- before_filter :check_logged_in, only: [:destroy, :edit, :update]
- def create
- @ad = Ad.new(params[:ad])
- @ad.save
- redirect_to "/ads/#{@ad.id}"
- end
- def destroy
- @ad = Ad.find(params[:id])
- @ad.destroy
- redirect_to "/ads/"
- end
- def edit
- @ad = Ad.find(params[:id])
- end
- def index
- @ads = Ad.find(:all)
- end
- def new
- @ad = Ad.new
- end
- def show
- @ad = Ad.find(params[:id])
- end
- def update
- @ad = Ad.find(params[:id])
- @ad.update_attributes(params[:ad])
- redirect_to "/ads/#{@ad.id}"
- end
- private
- def check_logged_in
- authenticate_or_request_with_http_basic("Ads") do |username, password|
- username == "admin" && password == "lolwat"
- end
- end
- end
Add Comment
Please, Sign In to add comment