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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:27:30+00:00 2026-06-15T01:27:30+00:00

I got a task to access param values for creating new user.My controller code

  • 0

I got a task to access param values for creating new user.My controller code for create is

def newstudent
    @student = Student.new(params)
   puts "+++++++++++"
   puts params.inspect

    if @student.save 
    respond_to do |format|
      format.html # new.html.erb
      format.json { render :json => @jtable }
    end
    end
  end

But by doing this i had got some error in terminal.It shows like this

ActiveModel::MassAssignmentSecurity::Error (Can't mass-assign protected attributes: action, controller):
  app/controllers/students_controller.rb:42:in `new'
  app/controllers/students_controller.rb:42:in `newstudent'

Please help me to solve the problem?

  • 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-15T01:27:31+00:00Added an answer on June 15, 2026 at 1:27 am

    This is my controller for add new student. By getting that error message you must reject controller and action using @student = Student.new(params.reject {|key,value| key =="controller" || key =="action"}) code.

     def newstudent
            @student = Student.new(params.reject {|key,value| key =="controller" || key =="action"})
    
            if @student.save 
              @jtable = {'Result' => 'OK','Record' => @student.attributes}
            else
             @jtable = {'Result' => 'ERROR','Message'=>'Empty'}
            end  
            respond_to do |format|
              format.html # new.html.erb
              format.json { render :json => @jtable }
            end
    
          end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a task of creating a read-only user for our ASP.Net MVC3 application.
I got a task to maintain a c# project, I found some code like
I got handed the task to create a Windows Phone app and i am
I am new in Java and have got as a task to find out,
If got a task to create a mobile application for iOS, Android and WP.
For school we got a task to create a multithreaded application. We chose to
I'm very new to SQL Server. I got a task from my boss where
I got an .ipa file from a customer (without source code access). This app
I've got task to do and I even dont know how to start. I
So, I've got task from my boss to install opendocman on our newly installed

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.