Project

General

Profile

Redmine > 3.0 : Redmine::SafeAttributes unable to mass-assign attributes.

Added by Rupesh J almost 10 years ago

Hello,

I have developed plugins in the following syntax,

class Book < ActiveRecord::Base
  unloadable
  include Redmine::SafeAttributes
  safe_attributes 'title', 'project', 'user_id', 'category'
end
class BooksController < ApplicationController
  unloadable
  before_filter :find_project_by_project_id, :authorize
..
  def create
    @book = Book.new
    @book.safe_attribues = params[:book]
    @book.save
  end
...
end

Now the problem, The log says that mass-assigment is not allowed ( 'Can't mass-assign protected attributes' ).
And the save fails.

I am not able to figure out what is that I am doing wrong.
Can anybody please suggest me the correct usage of these safe attributes.

Thanks.


    (1-1/1)