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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:01:12+00:00 2026-06-05T02:01:12+00:00

There is a mass assignment defined in sys_log model in our rails 3.1.4 app:

  • 0

There is a mass assignment defined in sys_log model in our rails 3.1.4 app:

attr_accessible :log_date, :user_name, :user_id, :user_ip, :action_logged, :as => :new_log

A method is defined in application_controller to save the log:

  def sys_logger(action_logged)
    log = SysLog.new(:log_date => Time.now, :user_id => session[:user_id], :user_name => session[:user_name], :user_ip => session[:user_ip],
                     :action_logged => action_logged, :as => :new_log)
    log.save
  end

However, the mass assignment does not work. Here is the warning message:

WARNING: Can't mass-assign protected attributes: log_date, user_id, user_name, 
user_ip, action_logged, as

:new_log is not working as defined. What’s wrong with the code above? Thanks so much.

  • 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-05T02:01:13+00:00Added an answer on June 5, 2026 at 2:01 am

    The :as => :new_log is now part of the hash of attributes, instead of a separate option you pass in.

    Adding some curly braces should help:

    def sys_logger(action_logged)
      log = SysLog.new({:log_date => Time.now, :user_id => session[:user_id],
                        :user_name => session[:user_name], :user_ip => session[:user_ip], 
                        :action_logged => action_logged }, :as => :new_log)
      log.save
    end
    

    Or assigning it temporarily:

    def sys_logger(action_logged)
      attrs = { :log_date => Time.now, :user_id => session[:user_id],
                :user_name => session[:user_name], :user_ip => session[:user_ip],
                :action_logged => action_logged }
      log = SysLog.new(attrs, :as => :new_log)
      log.save
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple rails app where user can send a mass email to
I was reading about scoped mass assignment in Rails 3.1 (Edge). I found this
Is there any way to format a USB mass storage device programmatically in Android?
We have a .NET application which our customers consider too large for mass deployment
it seems very slow for php to process mass amounts of strings, is there
Is there a way to have rails raise an error if an attempt is
In my Rails app I have Users. Users are asked for their home city
Is there a way to use SQL server to send mass email? or would
I have to create a mass insertion feature for our user administration tool. We
I am very confused by the following warning about mass assignment: WARNING: Can't mass-assign

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.