Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7502293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:48:57+00:00 2026-05-29T20:48:57+00:00

(I am new to paperclip) I have this model hierarchy: base model: class QuestDescription

  • 0

(I am new to paperclip)

I have this model hierarchy:

base model:

class QuestDescription < ActiveRecord::Base
end

inherited model:

class ImageDescription < QuestDescription
  has_attached_file :img
end

and I’m using Single Table Inheritance from ActiveRecord

[part of] schema.rb:

create_table "quest_descriptions", :force => true do |t|
  t.string   "type"
  t.datetime "img_updated_at"
  t.integer  "img_file_size"
  t.string   "img_file_name"
  t.string   "img_content_type"
  t.datetime "created_at",         :null => false
  t.datetime "updated_at",         :null => false
end

ImageDescription controller:

class ImageDescriptionsController < ApplicationController

  def new
    @imgD = ImageDescription.new
  end

  def create
    @imgD=ImageDescription.new(params[:imgD])
    if @imgD.save
      redirect_to :back, :flash => {:notice => "saved"} 
    else
      redirect_to :back, :flash => {:error => "error"} 
    end
  end

  def show
    @imgD=ImageDescription.find(params[:id])
  end
end    

new view (using formtastic):

<%= semantic_form_for @imgD do |form| %>
  <%= form.input :img%>
  <%= form.actions %>
<%end%>

show view:

<%= image_tag @imgD.img.url %>

when i use the new view (and select the file to upload), the POST is working, but no file is being saved/attached, the “img_file_size”, “img_file_name”, “img_content_type” are set to nil.

If I try to show it, the result is a “missing” field.

EDIT:

if i try to create a ImageDscription from the console, it works:

ImageDescription.create(:img => File.new(Rails.root + "public/images/grid.png"))
    (0.1ms) begin transaction
    SQL (31.9ms) INSERT INTO "quest_descriptions" ("created_at", "img_content_type", "img_file_name", "img_file_size", "img_updated_at", "type", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) ["created_at", Wed, 15 Feb 2012 00:07:48 UTC +00:00], ["img_content_type", "image/png"], ["img_file_name", "grid.png"], ["img_file_size", 206], ["img_updated_at", Wed, 15 Feb 2012 00:07:48 UTC +00:00], ["type", "ImageDescription"], ["updated_at", Wed, 15 Feb 2012 00:07:48 UTC +00:00] commit transaction
    => #
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:48:59+00:00Added an answer on May 29, 2026 at 8:48 pm

    really stupid mistake:

    @imgD=ImageDescription.new(params[:imgD])
    

    means nothing… right line is

    @imgD=ImageDescription.new(params[:image_description])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two models nested with accepts_nested_attributes_for : class Place < ActiveRecord::Base # Relations..
I currently have a nested forms model. The nested forms for the paperclip attachments
I'm very new to programming and have followed this screencast at emersonlackey.com on adding
Am new to RoR paperclip gem and i have been trying out some examples
I am new in Rails and web development... I have created a User model,
I have the following in my user model attr_accessible :avatar, :email validates_presence_of :email has_attached_file
I have a user model that is generated using Devise. I am extending this
How do you create rounded corners with Paperclip? I have found this solution which
New class is a subclass of the original object It needs to be php4
New to javascript/jquery and having a hard time with using this or $(this) to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.