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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:12:49+00:00 2026-06-04T17:12:49+00:00

I just using activeadmin gem: rails generate active_admin:resource Team rails generate active_admin:resource Players app/models

  • 0

I just using activeadmin gem:

rails generate active_admin:resource Team

rails generate active_admin:resource Players

app/models

class Team < ActiveRecord::Base
  has_many :players
  attr_accessible :description, :name
end

class Player < ActiveRecord::Base
  belongs_to :team
  attr_accessible :description, :name
end

app/controller/players_controller

class PlayersController < ApplicationController
    def create
        @team = Team.find(params[:team_id])
        @player = @team.players.create(params[:player])
    end
end

app/admin/

  ActiveAdmin.register Team do
  end

  ActiveAdmin.register Player do
  end

When I tried to create a new Player using the admin interface, I receive:

ActiveModel::MassAssignmentSecurity::Error in Admin::PlayersController#create

Can't mass-assign protected attributes: team_id

I know that I have to do something more, but what? Thanks a lot.

  • 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-04T17:12:51+00:00Added an answer on June 4, 2026 at 5:12 pm

    You need to add team_id to attr_accessible:

    class Player < ActiveRecord::Base
        belongs_to :team
        attr_accessible :description, :name, :team_id
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just adding ActiveAdmin to my app, I got a problem using show/edit/destroy action
Rails 2.3.5, just using Prototype in this project so far. I have a form
I'm just using StarUML to create my UML Class diagram and something is bothering
I just added active admin to my rails app and I'm unable to create
I am using camera in my app. I am just using intent to start
I just started using Active Admin Gem. I have a little bit of a
By default I mean just using the [Serializable] attribute on the class. I want
I have implemented the cancan with active_admin using below link. https://github.com/gregbell/active_admin/wiki/How-to-work-with-cancan Just in my
What is the difference between using Phusion Passenger or just using WEBrick (e.g., rails
I know that changing the ImageView resource is not big deal just using myImageView.setImageResource(mynewImageDrawable)

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.