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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:03:04+00:00 2026-06-18T04:03:04+00:00

I am using Rails 3.2.2 and am getting the following error. The form below

  • 0

I am using Rails 3.2.2 and am getting the following error. The form below uses a nested model and I am unable to locate the source of the error which I have been trying to locate for days now.


ActiveModel::MassAssignmentSecurity::Error in UsersController#create

Can't mass-assign protected attributes: blog

app/controllers/users_controller.rb:17:in `new'
app/controllers/users_controller.rb:17:in `create'

Variables for form

class HomeController < ApplicationController

  def index
    @user = User.new
    @blog = @user.blogs.build
  end
end

User form

<%= form_for @user do |f| %>
 <%= f.text_field :email, :class => 'textbox', :value => 'Email' %><br/><br/>
 <%= f.password_field :password, :class => 'textbox', :value => 'Password' %><br/><br/>
   <%= f.fields_for :blog do |b|%>
     <%= b.text_field :url, :class => 'textbox', :value => 'Blog URL' %></br></br>
   <% end %>

 <%= image_submit_tag("signup.png") %> <br/>
<% end %>

User Controller

class UsersController < ApplicationController

  def create
     @user = User.new(params[:user])   ############## << RUNTIME ERROR #############

     if @user.save 
       flash[:success] = "Welcome!"
       render 'user/success'             
     else
       render 'home/index'
     end
   end

Blog Model

class Blog < ActiveRecord::Base

   belongs_to :user
   attr_accessible :url, :type, :blog_id
   validates :url, :presence => true 

end

User Model

class User < ActiveRecord::Base

  has_many :blogs
  has_many :posts

  accepts_nested_attributes_for :blogs, :allow_destroy => true
  attr_accessible :email, :password, :user_id, :blogs_attributes 
end

Schemas

  create_table "blogs", :force => true do |t|
    t.integer  "user_id"
    t.string   "url"
    t.string   "type"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end


  create_table "users", :force => true do |t|
    t.string   "email"
    t.datetime "created_at",      :null => false
    t.datetime "updated_at",      :null => false
    t.string   "password_digest"
    t.string   "remember_token"
  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-18T04:03:05+00:00Added an answer on June 18, 2026 at 4:03 am

    Try to add an s on blogs like so. Should be blogs.

    <%= f.fields_for :blogs do |b|%>
         <%= b.text_field :url, :class => 'textbox', :value => 'Blog URL' %></br></br>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using gvim and rails.vim and getting the following error when attempting to run
I'm very new to Ruby on Rails, and have been getting the following error
I am using rails 2.3.8 with sphinx search, am getting the following error message
I have a Rails app getting the following error: Less::ParseError in Home#index Showing /Users/burtondav/sites/requestsys/app/views/layouts/application.html.erb
I am using Rails 3.1.3 and getting the following error when executing a cuke:
I am getting the following error when trying to upload an image using paperclip
I'm getting the following error with my Ruby 1.9 & Rails 2.3.4. This happens
Using Rails 3.0.3. I have the following route in routes.rb: match user/create_new_password/:reset_password_key =>users#create_new_password, :via=>[:get,
When I try to start my Rails server, I am getting the following error:
I ran bundle update on my rails app. I'm not getting the following error

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.