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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:52:43+00:00 2026-05-25T00:52:43+00:00

I’ve got a nested form in Rails 3 as follows that works just fine

  • 0

I’ve got a nested form in Rails 3 as follows that works just fine during creation. In the edit stage, I’m getting WARNING: Can’t mass-assign protected attributes: type. The form shouldn’t be trying to set “type” and isn’t doing so as far as I can tell from the parameters.

class TagSetNomination < ActiveRecord::Base
  belongs_to :pseud
  belongs_to :owned_tag_set

  has_many :fandom_nominations, :dependent => :destroy
  has_many :character_nominations, :dependent => :destroy
  has_many :relationship_nominations, :dependent => :destroy
  has_many :freeform_nominations, :dependent => :destroy

  accepts_nested_attributes_for :fandom_nominations, :character_nominations, :relationship_nominations, :freeform_nominations, {
    :allow_destroy => true,
    :reject_if => proc { |attrs| attrs[:tagname].blank? }
  }
....
end

All of those nomination classes are subclasses of this base class:

class TagNomination < ActiveRecord::Base
  belongs_to :tag_set_nomination

  ....
end

And here’s the relevant bit of my form:

<%= error_messages_for :tag_set_nomination %>

<%= form_for(@tag_set_nomination, :url => (@tag_set_nomination.new_record? ? tag_set_nominations_path(@tag_set) : tag_set_nomination_path(@tag_set, @tag_set_nomination)), :html => {:method => (@tag_set_nomination.new_record? ? :post : :put)}) do |f| %>

  <h4><%= ts("Tag Nominations") %></h4>
  <fieldset class="tagset">
    <dl>
      <% @tag_set_nomination.character_nominations.each_with_index do |character_nomination, index| %>
        <%= f.fields_for :character_nominations, character_nomination do |nom_form| %>
          <%= render 'tag_nominations', :nom_form => nom_form, :tag_type => 'character', :tag_nominations_counter => index %>
        <% end %>
      <% end %>
    </dl>
  </fieldset>

....
<% end %>

And some hopefully relevant bits from the log:

Started POST "/tag_sets/1/nominations/3" for 68.175.83.208 at 2011-08-23 02:59:08 +0000
Parameters: { ... "tag_set_nomination"=>{"character_nominations_attributes"=>{"0"=>{"tagname"=>"Sam", "parent_tagname"=>"", "tagnotes"=>"", "id"=>"12"}, "1"=>{"tagname"=>"Dean", "parent_tagname"=>"", "tagnotes"=>"", "id"=>"13"}, "2"=>{"tagname"=>"Yarbld", "parent_tagname"=>"Supernatural", "tagnotes"=>"some notes", "id"=>"16"}} ... }

SQL (0.1ms)  SELECT COUNT(*) FROM `tag_nominations` WHERE `tag_nominations`.`type` = 'CharacterNomination' AND (`tag_nominations`.tag_set_nomination_id = 3)
...
SQL (0.2ms)  ROLLBACK
Pseud Load (0.2ms)  SELECT `pseuds`.* FROM `pseuds` WHERE (`pseuds`.user_id = 8)
CharacterNomination Load (0.3ms)  SELECT `tag_nominations`.* FROM `tag_nominations` WHERE `tag_nominations`.`type` = 'CharacterNomination' AND (`tag_nominations`.tag_set_nomination_id = 3)
WARNING: Can't mass-assign protected attributes: type
WARNING: Can't mass-assign protected attributes: type
WARNING: Can't mass-assign protected attributes: type

And then I get dumped back to edit with no errors in the page. D:

Any ideas welcome! I am baffled.

  • 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-25T00:52:44+00:00Added an answer on May 25, 2026 at 12:52 am

    Okay, I figured it out, sigh. It had zero to do with any of the code I pasted. I had a before_save callback that was setting a value to either true or false — and of course, when it returned false, the before_save callback died and therefore the save got rolled back.

    facepalm

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
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 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 am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

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.