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 8251543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:16:16+00:00 2026-06-08T00:16:16+00:00

I’m in Rails 3.2.6 We have a nested form that was functioning up until

  • 0

I’m in Rails 3.2.6

We have a nested form that was functioning up until recently (not entirely certain when the error started occurring). Now the queries are passing in nulls.

Example output:

Started POST "/articles" for 127.0.0.1 at 2012-07-12 11:04:16 -0600
Processing by ArticlesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"thing=", "article"=>{"asset_attributes"=>{"name"=>"asdf", "short_desc"=>"asdfasdfsadg", "publish_date"=>"2012-07-12 11:4", "content_section_attributes"=>{"section_id"=>"1", "primary_section"=>"1"}, "section_ids"=>[""], "author_id"=>"", "display_authorbiography"=>"1", "last_modified_by"=>"1", "by_line"=>"", "content_image_attributes"=>{"image_id"=>""}, "keywords_string"=>"", "public_keywords_string"=>"", "meta_public_keywords"=>"", "meta_page_title"=>"", "meta_description"=>"", "meta_url_name"=>"", "guid"=>"", "canonical"=>"", "partner_id"=>"", "tagline"=>"", "series_id"=>"", "display_adsense"=>"1", "sweepstakes"=>""}, "content"=>"<p>asdfasgasg</p>"}, "img_size"=>"i01", "show_cap"=>"1", "img_pos"=>"left", "commit"=>"Create"}
  User Load (0.2ms)  SELECT `people`.* FROM `people` WHERE `people`.`type` IN ('User') AND `people`.`id` = 1 LIMIT 1 /*application:TmnCoreCms,controller:articles,action:create*/
  Section Load (0.1ms)  SELECT `sections`.* FROM `sections` /*application:TmnCoreCms,controller:articles,action:create*/
  Site Load (0.1ms)  SELECT `sites`.* FROM `sites` WHERE `sites`.`id` IN (1) /*application:TmnCoreCms,controller:articles,action:create*/
  Site Load (0.1ms)  SELECT `sites`.* FROM `sites` /*application:TmnCoreCms,controller:articles,action:create*/
  Section Load (0.1ms)  SELECT `sections`.* FROM `sections` WHERE `sections`.`site_id` IN (1) /*application:TmnCoreCms,controller:articles,action:create*/
  Role Load (0.1ms)  SELECT `roles`.* FROM `roles` INNER JOIN `user_roles` ON `roles`.`id` = `user_roles`.`role_id` WHERE `user_roles`.`user_id` = 1 /*application:TmnCoreCms,controller:articles,action:create*/
   (0.1ms)  BEGIN /*application:TmnCoreCms,controller:articles,action:create*/
   (0.1ms)  COMMIT /*application:TmnCoreCms,controller:articles,action:create*/
   (0.1ms)  BEGIN /*application:TmnCoreCms,controller:articles,action:create*/
   (0.1ms)  COMMIT /*application:TmnCoreCms,controller:articles,action:create*/
   (0.1ms)  BEGIN /*application:TmnCoreCms,controller:articles,action:create*/
  SQL (0.2ms)  INSERT INTO `articles` (`content`, `created_at`, `static_url`, `updated_at`) VALUES ('<p>asdfasgasg</p>', '2012-07-12 17:04:16', NULL, '2012-07-12 17:04:16') /*application:TmnCoreCms,controller:articles,action:create*/
  Article Load (0.3ms)  SELECT `articles`.* FROM `articles` WHERE `articles`.`id` = 25 LIMIT 1 /*application:TmnCoreCms,controller:articles,action:create*/
{}
  SQL (0.0ms)  INSERT INTO `assets` (`aasm_state`, `author_id`, `by_line`, `canonical`, `content_id`, `content_type`, `created_at`, `creator_id`, `display_adsense`, `display_authorbiography`, `guid`, `last_modified_by`, `legacyid`, `live_date`, `meta_description`, `meta_page_title`, `meta_public_keywords`, `meta_url_name`, `migration_guid`, `name`, `partner_id`, `publish_date`, `publish_version`, `series_id`, `short_desc`, `sweepstakes`, `tagline`, `updated_at`, `url_name`) VALUES ('new', NULL, NULL, NULL, 25, 'Article', '2012-07-12 17:04:16', NULL, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2012-07-12 17:04:16', NULL) /*application:TmnCoreCms,controller:articles,action:create*/
  SQL (0.2ms)  INSERT INTO `content_sections` (`content_id`, `content_type`, `created_at`, `primary_section`, `section_id`, `updated_at`) VALUES (53, 'Asset', '2012-07-12 17:04:16', 1, NULL, '2012-07-12 17:04:16') /*application:TmnCoreCms,controller:articles,action:create*/
   (33.6ms)  COMMIT /*application:TmnCoreCms,controller:articles,action:create*/
Redirected to http://localhost:3000/articles/53-
Completed 302 Found in 63ms (ActiveRecord: 35.3ms)

So as you can see the attributes are being sent. Our controller looks like this.

def new
    @article = Article.new
    @asset = @article.build_asset
  end

  def create
    @article = Article.new(params[:article])
    if @article.save
      flash[:notice] = 'Article was successfully created.'
      redirect_to @article
    else
      render :action => "new"
    end
  end

Relevant Model information:

class ContentType < ActiveRecord::Base
  self.abstract_class = true
  validates_presence_of :asset, :message => "Must have an asset"
  has_one :asset, :as => :content, :dependent => :destroy
  delegate :name, :url_name, :author, :creator, :publish_date, :short_desc,
           :aasm_state, :live_date, :keywords,
           :to => :asset, :allow_nil => true
  delegate :keywords_string, :public_keywords_string,
           :to => :asset,
           :allow_nil => true

  def initialize(*args)
    super(*args)
  end


  def to_param
    "#{asset.id}-#{url_name}"
  end
end

class Asset < ActiveRecord::Base
  include AASM
  include Keywordable
  attr_accessible :author_id,
                  :by_line,
                  :canonical,
                  :content_image_attributes,
                  :content_section_attributes,
                  :creator_id,
                  :display_adsense,
                  :display_authorbiography,
                  :guid,
                  :keywords,
                  :keywords_string,
                  :last_modified_by,
                  :meta_description,
                  :meta_page_title,
                  :meta_public_keywords,
                  :meta_url_name,
                  :name,
                  :partner_id,
                  :public_keywords_string,
                  :publish_date,
                  :related_content_attributes,
                  :section_ids,
                  :series_id,
                  :short_desc,
                  :sweepstakes,
                  :syndication_partner_ids,
                  :tagline,
                  :url_name

  belongs_to :author,  :class_name => 'Person'
  belongs_to :content, :polymorphic => true
  has_many :content_sections, :as => :content,  :conditions => {:primary_section => nil},  :dependent => :destroy

class Article < ContentType
  attr_accessible :images_attributes,
                  :content_images_attributes,
                  :content_text,
                  :content,
                  :asset_attributes,
                  :content_attributes

I really dislike this association set up but it is what it is. What’s happening is that the nested form

<%= f.fields_for :asset do |asset| %>
    <fieldset class="span8">
        <legend>Asset Description</legend>
        <div id='a_title'>
            <%= asset.label :name, "Title <span class='req'>*</span>".html_safe %>
            <%= asset.text_field :name, :class => 'asset_textarea counter', "data-max" => 255 %>
            <br/><span></span>
        </div>
        <div id='a_desc'>
            <%= asset.label :short_desc, "Teaser<span class='req'>*</span>".html_safe %>
                    <%= asset.text_area :short_desc, :class => "span7 asset_textarea counter", "data-max" => 255, :rows => 7 %>
                    <br/><span></span>
        </div>
    </fieldset>
<% end %>

Is somehow passing the fields and Rails is putting nulls in. I have no attr_accessible warnings. If I do an update on the article it will save the asset data. So something is going wrong on the initialization I think but I’m not sure what.

TLDR
Rails is not passing values into sql query despite attr_accessible having the nested attributes.

Edit

The contentTypesController has some before filters that I originally thought were the issue (they still may be I’m still figuring out how they are being used)

class ContentTypesController < ApplicationController

  before_filter :clean_syndication_partners, :only => [:update]
  before_filter :setup_existing_content_instance_variable, :except => [:index, :new, :create, :sort, :update_json, :vid_search, :search_library]
  #before_filter :setup_new_content_instance_variable, :only => [:new, :create]
  before_filter :get_sections
  before_filter :get_sites
  def clean_syndication_partners
    @asset = Asset.find(params[:id], :include => :content)
    @asset.syndication_partners = []
  end

  def get_sites
    @sites_all = Site.all(:include => :sections)
  end
  def get_sections
    @sections = Section.all(:include => :site)
  end

  def setup_existing_content_instance_variable
    @asset = Asset.find(params[:id], :include => :content) if @asset.nil?
    instance_variable_set("@#{@asset.content.class.name.underscore}", @asset.content)
  end

  # def setup_new_content_instance_variable
  #   pub_keyword = false
  #   current_class = self.controller_name.singularize
  #   @content_type = current_class.downcase
  #   if params[current_class]
  #     cur_content= current_class.camelize.constantize.new(params[current_class])
  #     #cur_content.asset = Asset.update_attributes(params[current_class][:asset_attributes])
  #   else
  #     cur_content= current_class.camelize.constantize.new
  #     #cur_content.asset=Asset.new
  #   end
  #   #cur_content.asset.creator=current_user
  #   #instance_variable_set(:@asset, cur_content.asset)
  #   instance_variable_set("@#{current_class}", cur_content)
  # end

end
  • 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-06-08T00:16:18+00:00Added an answer on June 8, 2026 at 12:16 am

    The issue ended up being an update to rails from 3.2.5 to 3.2.6. I think it’s due to our use of class inheritance for the sole purpose of sharing the asset relationship. We rolled it back and we’ll re-examine the relationship at a future time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.