Skip to content

Instantly share code, notes, and snippets.

@patrickberkeley
Created December 7, 2008 02:10
Show Gist options
  • Select an option

  • Save patrickberkeley/33011 to your computer and use it in GitHub Desktop.

Select an option

Save patrickberkeley/33011 to your computer and use it in GitHub Desktop.

Revisions

  1. patrickberkeley revised this gist Dec 8, 2008. 8 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
  2. patrickberkeley revised this gist Dec 8, 2008. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pages/show.html.erb
    Original file line number Diff line number Diff line change
    @@ -6,5 +6,5 @@

    <% for asset in @page.assets %>
    <p><%= image_tag asset.file.url %></p>
    <p>Small:<%= image_tag asset.file.url(:small) %></p>
    <p>Small:<%= image_tag asset.file.url(:medium) %></p>
    <% end %>
  3. patrickberkeley revised this gist Dec 8, 2008. 4 changed files with 14 additions and 8 deletions.
    5 changes: 5 additions & 0 deletions helpers/pages_helper.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    def add_asset_link(name)
    link_to_function name do |page|
    page.insert_html :bottom, :assets, :partial => 'asset', :object => Asset.new
    end
    end
    5 changes: 0 additions & 5 deletions pages/edit.html.erb
    Original file line number Diff line number Diff line change
    @@ -1,5 +0,0 @@
    <%= render :partial => 'shared/edit_side_nav', :locals => { :obj => @page } %>

    <h1>Editing page</h1>

    <%= render :partial => 'form', :locals => { :page => @page, :button_name => 'Update' } %>
    3 changes: 0 additions & 3 deletions pages/new.html.erb
    Original file line number Diff line number Diff line change
    @@ -1,3 +0,0 @@
    <h1>New page</h1>

    <%= render :partial => 'form', :locals => { :page => @page, :button_name => 'Create' } %>
    9 changes: 9 additions & 0 deletions pages/new.html.erb and pages/edit.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    <!-- new.html.erb -->
    <h1>New page</h1>

    <%= render :partial => 'form', :locals => { :page => @page, :button_name => 'Create' } %>

    <!-- edit.html.erb -->
    <h1>Editing page</h1>

    <%= render :partial => 'form', :locals => { :page => @page, :button_name => 'Update' } %>
  4. patrickberkeley revised this gist Dec 8, 2008. 2 changed files with 27 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions pages/index.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    <div class="side-nav actions">
    <%= link_to "New", new_page_path if logged_in? %>
    </div>

    <%= title('Pages', :h1)%>

    <div id="pages">
    <% for page in @pages %>
    <div class="page">
    <%= render :partial => 'shared/side_nav', :locals => { :obj => page, :edit_obj => edit_page_path(page) } %>
    <div class="main">
    <h2><%= page.name %></h2>
    <div class="content"><%= truncate(page.content) %></div>
    </div>
    </div>
    <% end %>
    </div>
    10 changes: 10 additions & 0 deletions pages/show.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <%= render :partial => 'shared/show_side_nav', :locals => { :obj => @event, :edit_obj => edit_page_path(@page) } %>

    <%= title(@page.name, :h1) %>

    <%= simple_format h(@page.content) %>

    <% for asset in @page.assets %>
    <p><%= image_tag asset.file.url %></p>
    <p>Small:<%= image_tag asset.file.url(:small) %></p>
    <% end %>
  5. patrickberkeley revised this gist Dec 8, 2008. 4 changed files with 10 additions and 284 deletions.
    87 changes: 0 additions & 87 deletions assets_controller.rb
    Original file line number Diff line number Diff line change
    @@ -1,87 +0,0 @@
    class AssetsController < ApplicationController
    before_filter :login_required

    # GET /assets
    # GET /assets.xml
    def index
    @assets = Asset.find(:all)

    respond_to do |format|
    format.html # index.html.erb
    format.xml { render :xml => @assets }
    end
    end

    # GET /assets/1
    # GET /assets/1.xml
    def show
    @asset = Asset.find(params[:id])

    respond_to do |format|
    format.html # show.html.erb
    format.xml { render :xml => @asset }
    end
    end

    # GET /assets/new
    # GET /assets/new.xml
    def new
    @asset = Asset.new

    respond_to do |format|
    format.html # new.html.erb
    format.xml { render :xml => @asset }
    end
    end

    # GET /assets/1/edit
    def edit
    @asset = Asset.find(params[:id])
    end

    # POST /assets
    # POST /assets.xml
    def create
    @asset = Asset.new(params[:asset])

    respond_to do |format|
    if @asset.save
    flash[:notice] = 'Asset was successfully created.'
    format.html { redirect_to(@asset) }
    format.xml { render :xml => @asset, :status => :created, :location => @asset }
    else
    format.html { render :action => "new" }
    format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }
    end
    end
    end

    # PUT /assets/1
    # PUT /assets/1.xml
    def update
    @asset = Asset.find(params[:id])

    respond_to do |format|
    if @asset.update_attributes(params[:asset])
    flash[:notice] = 'Asset was successfully updated.'
    format.html { redirect_to(@asset) }
    format.xml { head :ok }
    else
    format.html { render :action => "edit" }
    format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }
    end
    end
    end

    # DELETE /assets/1
    # DELETE /assets/1.xml
    def destroy
    @asset = Asset.find(params[:id])
    @asset.destroy

    respond_to do |format|
    format.html { redirect_to(assets_url) }
    format.xml { head :ok }
    end
    end
    end
    194 changes: 0 additions & 194 deletions error when creating multiple attachments with paperclip
    Original file line number Diff line number Diff line change
    @@ -1,194 +0,0 @@
    ActiveRecord::UnknownAttributeError in PagesController#create

    unknown attribute: file

    Application Trace | Framework Trace | Full Trace

    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `build_association'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:413:in `build_record'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:98:in `build'
    app/models/page.rb:11:in `new_asset_attributes='
    app/models/page.rb:10:in `each'
    app/models/page.rb:10:in `new_asset_attributes='
    app/controllers/pages_controller.rb:54:in `new'
    app/controllers/pages_controller.rb:54:in `create'

    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `build_association'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:413:in `build_record'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:98:in `build'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `perform_action_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:617:in `call_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/rescue.rb:136:in `perform_action_without_caching'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:48:in `cache'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/query_cache.rb:8:in `cache'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `process_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/session_management.rb:134:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:401:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:180:in `handle_request'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:107:in `dispatch_unlocked'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:120:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:129:in `dispatch_cgi'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:36:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load_without_new_constant_marking'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
    /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/servers/mongrel.rb:64
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/server.rb:49
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    script/server:3

    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `build_association'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:413:in `build_record'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:98:in `build'
    app/models/page.rb:11:in `new_asset_attributes='
    app/models/page.rb:10:in `each'
    app/models/page.rb:10:in `new_asset_attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
    app/controllers/pages_controller.rb:54:in `new'
    app/controllers/pages_controller.rb:54:in `create'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `perform_action_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:617:in `call_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/rescue.rb:136:in `perform_action_without_caching'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:48:in `cache'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/query_cache.rb:8:in `cache'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `process_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/session_management.rb:134:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:401:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:180:in `handle_request'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:107:in `dispatch_unlocked'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:120:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:129:in `dispatch_cgi'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:36:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load_without_new_constant_marking'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
    /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/servers/mongrel.rb:64
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/server.rb:49
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    script/server:3

    Request

    Parameters:

    {"commit"=>"Create",
    "authenticity_token"=>"7148b67898a9250e22b34b737c428fb6ee59ec9a",
    "page"=>{"permalink"=>"a_permalink",
    "name"=>"a name",
    "new_asset_attributes"=>[{"file"=>#<ActionController::UploadedStringIO:0x212c328>}],
    "content"=>"some content"}}

    Show session dump

    ---
    :user_id: 1
    :return_to:
    flash: !map:ActionController::Flash::FlashHash {}


    Response

    Headers:

    {"cookie"=>[],
    "Content-Type"=>"",
    "Cache-Control"=>"no-cache"}

    5 changes: 5 additions & 0 deletions pages/edit.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    <%= render :partial => 'shared/edit_side_nav', :locals => { :obj => @page } %>

    <h1>Editing page</h1>

    <%= render :partial => 'form', :locals => { :page => @page, :button_name => 'Update' } %>
    8 changes: 5 additions & 3 deletions schema.rb
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,13 @@
    create_table "assets", :force => true do |t|
    t.string "name"
    t.text "description"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string "file_file_name"
    t.string "file_content_type"
    t.integer "file_file_size"
    t.datetime "file_updated_at"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer "page_id"
    end

    create_table "pages", :force => true do |t|
    @@ -13,5 +16,4 @@
    t.text "content"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer "asset_id"
    end
  6. patrickberkeley revised this gist Dec 7, 2008. 2 changed files with 185 additions and 0 deletions.
    87 changes: 87 additions & 0 deletions assets_controller.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,87 @@
    class AssetsController < ApplicationController
    before_filter :login_required

    # GET /assets
    # GET /assets.xml
    def index
    @assets = Asset.find(:all)

    respond_to do |format|
    format.html # index.html.erb
    format.xml { render :xml => @assets }
    end
    end

    # GET /assets/1
    # GET /assets/1.xml
    def show
    @asset = Asset.find(params[:id])

    respond_to do |format|
    format.html # show.html.erb
    format.xml { render :xml => @asset }
    end
    end

    # GET /assets/new
    # GET /assets/new.xml
    def new
    @asset = Asset.new

    respond_to do |format|
    format.html # new.html.erb
    format.xml { render :xml => @asset }
    end
    end

    # GET /assets/1/edit
    def edit
    @asset = Asset.find(params[:id])
    end

    # POST /assets
    # POST /assets.xml
    def create
    @asset = Asset.new(params[:asset])

    respond_to do |format|
    if @asset.save
    flash[:notice] = 'Asset was successfully created.'
    format.html { redirect_to(@asset) }
    format.xml { render :xml => @asset, :status => :created, :location => @asset }
    else
    format.html { render :action => "new" }
    format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }
    end
    end
    end

    # PUT /assets/1
    # PUT /assets/1.xml
    def update
    @asset = Asset.find(params[:id])

    respond_to do |format|
    if @asset.update_attributes(params[:asset])
    flash[:notice] = 'Asset was successfully updated.'
    format.html { redirect_to(@asset) }
    format.xml { head :ok }
    else
    format.html { render :action => "edit" }
    format.xml { render :xml => @asset.errors, :status => :unprocessable_entity }
    end
    end
    end

    # DELETE /assets/1
    # DELETE /assets/1.xml
    def destroy
    @asset = Asset.find(params[:id])
    @asset.destroy

    respond_to do |format|
    format.html { redirect_to(assets_url) }
    format.xml { head :ok }
    end
    end
    end
    98 changes: 98 additions & 0 deletions pages_controller.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,98 @@
    class PagesController < ApplicationController
    before_filter :login_required, :except => [ :show ]

    # GET /pages
    # GET /pages.xml
    def index
    @pages = Page.find(:all)

    respond_to do |format|
    format.html # index.html.erb
    format.xml { render :xml => @pages }
    end
    end

    # GET /pages/1
    # GET /pages/1.xml
    def show
    if params[:permalink]
    @page = Page.find_by_permalink(params[:permalink])
    raise ActiveRecord::RecordNotFound, "Page not found." if @page.nil?
    respond_to do |format|
    format.html # show.html.erb
    format.xml { render :xml => @page }
    end
    else
    @page = Page.find(params[:id])
    respond_to do |format|
    format.html # show.html.erb
    format.xml { render :xml => @page }
    end
    end
    end

    # GET /pages/new
    # GET /pages/new.xml
    def new
    @page = Page.new
    @page.assets.build

    respond_to do |format|
    format.html # new.html.erb
    format.xml { render :xml => @page }
    end
    end

    # GET /pages/1/edit
    def edit
    @page = Page.find(params[:id])
    end

    # POST /pages
    # POST /pages.xml
    def create
    @page = Page.new(params[:page])

    respond_to do |format|
    if @page.save
    flash[:notice] = 'Page was successfully created.'
    format.html { redirect_to(@page) }
    format.xml { render :xml => @page, :status => :created, :location => @page }
    else
    format.html { render :action => "new" }
    format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
    end
    end
    end

    # PUT /pages/1
    # PUT /pages/1.xml
    def update
    params[:page][:existing_asset_attributes] ||= {}

    @page = Page.find(params[:id])

    respond_to do |format|
    if @page.update_attributes(params[:page])
    flash[:notice] = 'Page was successfully updated.'
    format.html { redirect_to(@page) }
    format.xml { head :ok }
    else
    format.html { render :action => "edit" }
    format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
    end
    end
    end

    # DELETE /pages/1
    # DELETE /pages/1.xml
    def destroy
    @page = Page.find(params[:id])
    @page.destroy

    respond_to do |format|
    format.html { redirect_to(pages_url) }
    format.xml { head :ok }
    end
    end
    end
  7. patrickberkeley revised this gist Dec 7, 2008. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions pages/_asset.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <div class="asset">
    <% new_or_existing = asset.new_record? ? 'new' : 'existing' %>
    <% prefix = "page[#{new_or_existing}_asset_attributes][]" %>

    <% fields_for prefix, asset do |asset_form| -%>
    <p>
    Asset: <%= asset_form.file_field :file %>
    <%= link_to_function "remove", "$(this).up('.asset').remove()" %>
    </p>
    <% end -%>
    </div>
  8. patrickberkeley revised this gist Dec 7, 2008. 5 changed files with 85 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions asset.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    class Asset < ActiveRecord::Base
    belongs_to :page

    has_attached_file :file, :styles => { :medium => "300x300>", :thumb => "100x100>" }
    end
    32 changes: 32 additions & 0 deletions page.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    class Page < ActiveRecord::Base
    has_many :assets, :dependent => :destroy

    validates_associated :assets
    validates_presence_of :name, :permalink

    after_update :save_assets

    def new_asset_attributes=(asset_attributes)
    asset_attributes.each do |attributes|
    assets.build(attributes)
    end
    end

    def existing_asset_attributes=(asset_attributes)
    assets.reject(&:new_record?).each do |asset|
    attributes = asset_attributes[asset.id.to_s]
    if attributes
    asset.attributes = attributes
    else
    asset.delete(asset)
    end
    end
    end

    def save_assets
    assets.each do |asset|
    asset.save(false)
    end
    end

    end
    28 changes: 28 additions & 0 deletions pages/_form.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    <%= error_messages_for :page %>

    <% form_for @page, :html => { :multipart => true } do |f| %>
    <p>
    <%= f.label :name %><br />
    <%= f.text_field :name %>
    </p>
    <p>
    <%= f.label :permalink %><br />
    <%= f.text_field :permalink %>
    </p>
    <p>
    <%= f.label :content %><br />
    <%= f.text_area :content %>
    </p>
    <div id="assets">
    Attach a file or image<br />
    <%= render :partial => 'asset', :collection => @page.assets %>
    </div>
    <p>
    <%= add_asset_link "Add a file" %>
    </p>
    <p>
    <%= f.submit button_name %>
    </p>
    <% end %>

    <%= link_to 'Cancel', pages_path %>
    3 changes: 3 additions & 0 deletions pages/new.html.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    <h1>New page</h1>

    <%= render :partial => 'form', :locals => { :page => @page, :button_name => 'Create' } %>
    17 changes: 17 additions & 0 deletions schema.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    create_table "assets", :force => true do |t|
    t.string "file_file_name"
    t.string "file_content_type"
    t.integer "file_file_size"
    t.datetime "file_updated_at"
    t.datetime "created_at"
    t.datetime "updated_at"
    end

    create_table "pages", :force => true do |t|
    t.string "name"
    t.string "permalink"
    t.text "content"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer "asset_id"
    end
  9. patrickberkeley created this gist Dec 7, 2008.
    194 changes: 194 additions & 0 deletions error when creating multiple attachments with paperclip
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,194 @@
    ActiveRecord::UnknownAttributeError in PagesController#create

    unknown attribute: file

    Application Trace | Framework Trace | Full Trace

    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `build_association'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:413:in `build_record'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:98:in `build'
    app/models/page.rb:11:in `new_asset_attributes='
    app/models/page.rb:10:in `each'
    app/models/page.rb:10:in `new_asset_attributes='
    app/controllers/pages_controller.rb:54:in `new'
    app/controllers/pages_controller.rb:54:in `create'

    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `build_association'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:413:in `build_record'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:98:in `build'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `perform_action_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:617:in `call_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/rescue.rb:136:in `perform_action_without_caching'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:48:in `cache'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/query_cache.rb:8:in `cache'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `process_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/session_management.rb:134:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:401:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:180:in `handle_request'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:107:in `dispatch_unlocked'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:120:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:129:in `dispatch_cgi'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:36:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load_without_new_constant_marking'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
    /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/servers/mongrel.rb:64
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/server.rb:49
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    script/server:3

    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/reflection.rb:157:in `build_association'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:413:in `build_record'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/associations/association_collection.rb:98:in `build'
    app/models/page.rb:11:in `new_asset_attributes='
    app/models/page.rb:10:in `each'
    app/models/page.rb:10:in `new_asset_attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2579:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2575:in `attributes='
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/base.rb:2276:in `initialize'
    app/controllers/pages_controller.rb:54:in `new'
    app/controllers/pages_controller.rb:54:in `create'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:1213:in `perform_action_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:617:in `call_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/rescue.rb:136:in `perform_action_without_caching'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:48:in `cache'
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.0/lib/active_record/query_cache.rb:8:in `cache'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `send'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:533:in `process_without_filters'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/session_management.rb:134:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/base.rb:401:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:180:in `handle_request'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:107:in `dispatch_unlocked'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:120:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:119:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:129:in `dispatch_cgi'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.0/lib/action_controller/dispatcher.rb:36:in `dispatch'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `synchronize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in `process'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `each'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load_without_new_constant_marking'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:141:in `load'
    /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/servers/mongrel.rb:64
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:507:in `new_constants_in'
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:148:in `require'
    /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.0/lib/commands/server.rb:49
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    script/server:3

    Request

    Parameters:

    {"commit"=>"Create",
    "authenticity_token"=>"7148b67898a9250e22b34b737c428fb6ee59ec9a",
    "page"=>{"permalink"=>"a_permalink",
    "name"=>"a name",
    "new_asset_attributes"=>[{"file"=>#<ActionController::UploadedStringIO:0x212c328>}],
    "content"=>"some content"}}

    Show session dump

    ---
    :user_id: 1
    :return_to:
    flash: !map:ActionController::Flash::FlashHash {}


    Response

    Headers:

    {"cookie"=>[],
    "Content-Type"=>"",
    "Cache-Control"=>"no-cache"}