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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:49:26+00:00 2026-05-31T23:49:26+00:00

I make a carpooling application. When I want to create a new Route, I

  • 0

I make a carpooling application. When I want to create a new Route, I have this error:

ActiveModel::MassAssignmentSecurity::Error in RoutesController#create
Can't mass-assign protected attributes: place_ids

The Models are looking like this:

class Route < ActiveRecord::Base
  #  id             :integer         not null, primary key
  #  start_place_id :integer
  #  end_place_id   :integer
  #  start_time     :datetime
  #  end_time       :datetime
  #  car_id         :integer
  belongs_to :car
  has_many :places
  has_and_belongs_to_many :users
  attr_accessible :start_place_id, :end_place_id, :start_time, :end_time, :car_id
end

class Place < ActiveRecord::Base
  has_many :routes
  attr_accessible :name, :address, :lat, :long, :description
end

class Car < ActiveRecord::Base
  has_many :routes
  attr_accessible :car_type, :license_plate, :seats_num, :motorway_vignette_expeier
end

The _form.html.erb of the Routes looking like this:

<%= simple_form_for @route do |f| %>
  <%= render 'shared/error_messages', :object => f.object %>
  <%= f.association :places %>
  <%= f.association :places %>
  <%= f.input :start_time %>
  <%= f.input :end_time %>
  <%= f.association :car %>
  <%= f.button :submit %>
<% end %>

The log is writing this:

Started POST "/routes" for 127.0.0.1 at 2012-03-23 15:41:37 +0100
Processing by RoutesController#create as HTML
  Parameters: {"utf8"=>"✓", "route"=>{"place_ids"=>["", "4", "", "1"], "start_time(1i)"=>"2012", "start_time(2i)"=>"3", "start_time(3i)"=>"23", "start_time(4i)"=>"14", "start_time(5i)"=>"41", "end_time(1i)"=>"2012", "end_time(2i)"=>"3", "end_time(3i)"=>"23", "end_time(4i)"=>"14", "end_time(5i)"=>"41", "car_id"=>"1"}, "commit"=>"Create Route"}
Completed 500 Internal Server Error in 1ms

ActiveModel::MassAssignmentSecurity::Error (Can't mass-assign protected attributes: place_ids):
  app/controllers/routes_controller.rb:15:in `new'
  app/controllers/routes_controller.rb:15:in `create'

I don’t understand, why it makes a 4 element long array for place_ids (“place_ids”=>[“”, “4”, “”, “1”], ).
And I don’t understand, why it write MassAssignment, when I wrote in the model attr_accessible…
I did similar in rails 3.0.0, and it worked. I think simple_form changed something…
Why he write place_ids? Why not start_place_id and end_place_id?

I uploaded the full project to github: https://github.com/Koli14/telekocsi2

The environment is:

ruby 1.9.2p290

Rails 3.2.1

simple_form (2.0.1)

Ubuntu 11.10

  • 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-31T23:49:27+00:00Added an answer on May 31, 2026 at 11:49 pm

    I think you probably want another look at your associations. It seems to me that a route should belong to an end place and belong to a start place rather than have many places (unless you are including waypoints). A clue that this may be the case is the foreign keys in your route model.

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

Sidebar

Related Questions

I make API calls when create a user but I don't want do this
I make this async webrequest call mutliple times(can be twice or thrice or even
I make this call in my application.js file but it doesn't seem to return
(Make this CW if needed) We are two developers working on a web application
begin # make a new outgoing call @call = @client.account.calls.create( :from => '+1*********', :to
I make services folder in my Zend project and i create new php file
I make multiple web requests from an Android application I'm working on. I want
I make the problem shorter. Actually I have data much longer than this. I
Make a new AS3 Document in Flash, paste in the following code and run
I make a user control and then want to include it on a page

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.