Questions tagged [attr-accessible]

attr-accessible creates a white-list of editable attributes

attr-accessible is reference of Ruby on Rails new "attr_accessible" feature. It lets programmers define a white-list of attributes that can be modified by a user through its user interface.

104 questions
0
votes
1 answer

How to access nested attributes hash in model validation without attr_accessible in rails 4?

I want to create a validation for the length of records of a nested attributes relation in rails 4. Due to the restriction on attr_accessible, I can't seem to access the nested fields attributes hash. This is the validation I'm trying to…
e3matheus
  • 2,112
  • 1
  • 20
  • 28
0
votes
3 answers

Rails 4 validation attr_acessible error

I'm following Micheal Hartl's Ruby on Rails Tutorial Book.I'm testing validation for the presence of name and email in the sample_app.In rails console, I'm running user = User.new(:email => "user@example.com") to test an absent name value but I'm…
yaboiduke
  • 652
  • 7
  • 20
0
votes
2 answers

Import CSV to database using Rails 4.0.3

I am new to Ruby on Rails. I am using Rails 4.0.3, Ruby 1.9.3. I tried to import CSV file from the sample "396-importing-csv-and-excel-master" But it is throwing error. Error: attr_accessible is no longer in use and suggests to use Strong…
0
votes
1 answer

Rails 3 form helper for models with nested attributes

I'm baffled with forms for nested attributes Here's my model: class User < ActiveRecord::Base has_one :user_email_preference, :dependent => :destroy accepts_nested_attributes_for :user_email_preference attr_accessible…
Ian Lin
  • 384
  • 1
  • 5
  • 20
0
votes
1 answer

Commenting model not saving and displaying :body section of comments

I'm new to rails and am having challenges adding a commenting system to my listings model. Effectively I have listings that are created by users, and I want the ability to allow other users to make comments on these listings. What I have so…
dmt2989
  • 1,610
  • 3
  • 17
  • 30
0
votes
1 answer

Virtual attribute in a Rails app - why is attr_writer not making my input work with my getter and setter methods?

I'm trying to roll my own tagging system. My setup is (at the moment) much like acts_as_taggable_on, with Tags, Taggable objects, and Taggings to relate the one to the other. Taggable is a module, which will be included in Events, Users, and…
0
votes
2 answers

Mass Security Assignment to undefined method `attr_accessible

I'm using Rails 3.2.13 and Refinery with Inquiries gem. I needed to add a field to the contact form provided by the Inquiries gem; however, I get this error “WARNING: Can't mass-assign protected attributes” I had read to NOT disable the…
nil
  • 2,238
  • 1
  • 19
  • 28
0
votes
1 answer

Get type of user modifying record - Rails

I have in my model: attr_accessible :name, as: :admin And in my active admin initializer: module ActiveAdmin class BaseController with_role :admin end end Is it possible to get the role that is editing the record in the model, to do…
sites
  • 21,417
  • 17
  • 87
  • 146
0
votes
1 answer

Commenting rails attr_accessible fields with RDoc

How do I add comments to an attr_accessible field in a Rails class so that it will be picked up by RDoc (or Yard). Here is my sample code, but the comment is not appearing in the generated RDoc files (though method commenting works fine): class…
Sean Huber
  • 3,945
  • 2
  • 26
  • 31
0
votes
3 answers

rails update_attributes don't update value

When trying to update the value read_at from Message model it don't have any kind of effect using the update_attributes function. Here is the Message table class CreateMessages < ActiveRecord::Migration def change create_table :messages do…
fejao
  • 23
  • 1
  • 3
0
votes
1 answer

Rails security attr_accessible users making unauthorized requests

Ever since I learned about the security holes with attr_accessible, I have been trying to be very careful when it comes to this type of stuff, so I just need some clarification. Let's say I have a Comment model and it has attr_accessible…
chosen2
  • 15
  • 3
0
votes
1 answer

Building profile in user model for registration, is user_id in attr_accessible big mistake?

Using devise as my authentication system I would like to build my profile on user registration. I read many topics about this on SO, and decided to take the approach of building the profile within the model: profile.rb class Profile <…
benoitr
  • 6,025
  • 7
  • 42
  • 67
0
votes
3 answers

Getting "Can't mass-assign protected attributes:" for nested_attributes

I am on Rails3, I have two model, User, and Post. User has Posts as nested attributes. when I try to save user then I am getting Can't mass-assign protected attributes:.....
0
votes
1 answer

Can't mass-assign protected attributes: even if attr_accessible already added

Can't mass assign :title, :url and :about even if attr_accessible attributes already added. It's fine on rails console but not on online form. Post Model: class Post < ActiveRecord::Base attr_accessible :about, :downv, :names, :points, :title,…
0
votes
1 answer

MassAssignment Error when Attribute in attr_accessible

I am getting a ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: title when I have attr_accessible :title in the model. See the code and output of a console call below: User model # == Schema Information # # Table…
Ryan
  • 641
  • 5
  • 17