Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is Paperclip giving me this "unknown attribute" error?
    primarykey
    data
    text
    <p>I have...</p> <p><strong>/config/routes.rb</strong>:</p> <pre><code>resources :surveys do resources :screenshots end </code></pre> <p><strong>/app/models/survey.rb</strong>:</p> <pre><code>has_many :screenshots </code></pre> <p><strong>/app/models/screenshot.rb</strong>:</p> <pre><code>attr_accessible :name, :shot, :screenshot, :result_ids belongs_to :survey has_many :results has_attached_file :shot, :default_url =&gt; ActionController::Base.helpers.asset_path('missing_:style.png') </code></pre> <p><strong>/db/schema.rb</strong>:</p> <pre><code>create_table "screenshots", :force =&gt; true do |t| t.integer "survey_id" t.boolean "resetting_cache", :default =&gt; false t.string "url" t.string "shot_file_name" t.string "shot_content_type" t.integer "shot_file_size" t.datetime "shot_updated_at" t.boolean "include", :default =&gt; false t.datetime "created_at", :null =&gt; false t.datetime "updated_at", :null =&gt; false t.string "name" end </code></pre> <p><strong>/app/controllers/screenshots_controller.rb</strong>:</p> <pre><code>def new @survey = Survey.find(params[:survey_id]) @competitor = @survey.competitor @screenshot = Screenshot.new end def create @survey = Survey.find(params[:survey_id]) @screenshot = Screenshot.new(params[:screenshot]) @competitor = @survey.competitor flash[:notice] = "Screenshot was successfully added." if @screenshot.save respond_with(@survey, @screenshot) end </code></pre> <p><strong>/app/views/screenshots/_form.html.haml</strong>:</p> <pre><code>= simple_form_for [@survey, @screenshot] do |f| = f.error_notification = f.file_field :shot = f.association :results, :collection =&gt; @survey.selected_results = f.button :submit, :label =&gt; "Save", :id =&gt; "submit_screenshot" </code></pre> <p>Does anyone know why <code>@screenshot = Screenshot.new(params[:screenshot])</code> is giving me an <code>unknown attribute: screenshot</code> error?</p> <p>Typical <code>params</code> at that point would be:</p> <pre><code>=&gt; {"utf8"=&gt;"✓", "authenticity_token"=&gt;"t33SO+/mpPlQY/+7+5iRTe6O2zL/MtqisYXyghzkLY8=", "screenshot"=&gt; {"screenshot"=&gt; #&lt;ActionDispatch::Http::UploadedFile:0x007fd5cca0ace0 @content_type="image/png", @headers= "Content-Disposition: form-data; name=\"screenshot[screenshot]\"; filename=\"youtube.png\"\r\nContent-Type: image/png\r\n", @original_filename="youtube.png", @tempfile= #&lt;File:/var/folders/k9/vnpft_6d7qs6xmdb9_4svvmw0000gn/T/RackMultipart20131125-3030-1gmx1sy&gt;&gt;, "result_ids"=&gt;["", "29857"]}, "commit"=&gt;"Create Screenshot", "action"=&gt;"create", "controller"=&gt;"screenshots", "survey_id"=&gt;"14564"} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload