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

  • Home
  • SEARCH
  • 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 7983263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:54:45+00:00 2026-06-04T10:54:45+00:00

I have looked at other posts and can’t see what I’m doing wrong. I’m

  • 0

I have looked at other posts and can’t see what I’m doing wrong.
I’m getting this error:

ActiveModel::MassAssignmentSecurity::Error in ProjectsController#create

Can't mass-assign protected attributes: blog_post

Here are my two models and my form. I’m under the impression that there’s nothing special that needs to be in the project controller. Is there anything in the project or blog_post controller that could screw this up?

project.rb

class Project < ActiveRecord::Base
  attr_accessible :name, :category_id, :user_id, :goal, :about, :headline, :image_url, :about_html, :blog_post_attributes

  has_many :blog_posts, :dependent => :destroy
  accepts_nested_attributes_for :blog_posts
end

blog_post.rb

class BlogPost < ActiveRecord::Base
  attr_accessible :project_id, :user_id, :title, :blog_text, :commentable, :private
  belongs_to :project
  has_many :blog_post_replies, :dependent => :destroy
end

projects/_new_form.html.erb

<%= semantic_form_for @project do |f|  %>
<%= f.semantic_errors :state %>

<%= f.input :name, :as => :string %>
<%= f.input :headline, :as => :string %>
<%= f.input :about %>
<%= f.input :image_url, :as => :file %>
<%= f.input :category , :include_blank => false%>
<div class="well">
<%= f.semantic_fields_for :blog_post do |blog_post| %>
    <%= blog_post.input :title, :as => :string, :label => "First Blog Post Title" %>
    <%= blog_post.input :blog_text, :as => :text, :label => "First Blog Post Text" %>
<% end %>
</div>
<%= f.action :submit, :as => :button %>
<% end %>

EDIT If I use the suggested Formtastic format:

<%= f.input :title, :for => :blog_post %>
<%= f.input :blog_text, :for => :blog_post %>

I get this error; which makes me think it’s not seeing the nested attributes at all:

NoMethodError in Projects#new

undefined method `title' for #<Project:0x007fb044745f58>
  • 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-04T10:54:46+00:00Added an answer on June 4, 2026 at 10:54 am

    The error is here:

    <%= f.semantic_fields_for :blog_post do |blog_post| %>
    

    It should be:

    <%= f.semantic_fields_for :blog_posts do |blog_post| %>
    

    (:blog_posts instead of :blog_post)

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

Sidebar

Related Questions

I have looked at the other posts, but this question is different than them.
I have seen al most all the other posts about this, but I can't
I have looked and tried but don't see where I can stop some being
(I've looked at many other similar posts on SO and have unfortunately not been
I've looked at several other posts, and I have yet to find a clear
I looked at all the other posts on this and none of them came
I'm having an issue removing/hiding the status bar. I have looked at other posts
I can't seem to figure this out. I've looked at a couple SO posts
I have looked at some of the other posts made on similar topics but
I have looked for similar questions, but could find none other than the difference

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.