My Recent Pastes (21 and counting)

Pastes by winson (21 and counting)

Pages:

Below are the 6 most recent pasties by winson.

May 02, 2007
11:23PM EDT
by winson

## publisher_controller.rb
class Admin::PublisherController < ApplicationController
  def login
    return unless request.post?
    publisher = Publisher.find_by_name(params[:publisher][:name])

May 02, 2007
6:26AM EDT
by winson

class ApplicationController < ActionController::Base
  
  private
  
  # Initialize shopping cart.

May 02, 2007
6:24AM EDT
by winson

class ApplicationController < ActionController::Base
  
  private
  
  # Initialize shopping cart.

May 02, 2007
5:46AM EDT
by winson

## publisher_controller.rb
class Admin::PublisherController < ApplicationController
# Login & check password, then goes to index.
  def login
    @page_title = 'Publisher login'

May 02, 2007
5:41AM EDT
by winson

  # Add book to shopping cart.
  def add
    @book = Book.find(params[:id])
    # Added by sending book object.
    flash[:cart_notice] = "Added <em>#{@book.title}.</em>" if @cart.add @book

May 02, 2007
5:41AM EDT
by winson

  # Using ActionController’s rescue_action_in_public method we can capture these exceptions and throw 404’s accordingly.
  def rescue_action_in_public(e)
    if e.is_a? ActiveRecord::RecordNotFound
      render :file => "#{RAILS_ROOT}/public/404.html",
             :status => '404 Not Found'

Previous page