Displaying 20 results from an estimated 139 matches for "attr_accessible".
2011 Mar 07
3
difference between attr_accessor and attr_accessible?
Hi,
What''s the difference between attr_accessor and attr_accessible?
Is attr_accessor to create a virtual variable/object and attr_accessible
makes it accessible? Do you need attr_accessible if you already have
attr_accessor?
Thanks!
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "R...
2007 Jan 24
2
attr_accessor vs attr_accessible
Please guide me how to use those two methods. I can''t differentiate
them. I was doing something on my model and I have put one field in the
attr_accessible method. After that when I try to run the app the app
always says my other fields are blank, but they''re all filled up.
What''s wrong with it?
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups &q...
2012 Jul 09
10
attr_accessible on some properties + attr_protected on others makes class 'open-by-default'
(I posted this as a bug in GitHub
(https://github.com/rails/rails/issues/7018), but then someone there told
me I should post it here, so here it is.)
If you set attr_accessible on some properties in an ActiveRecord-descended
class, and then attr_protected on others - the class becomes ''default-open''
- if any properties are missed or added later, they will be accessible by
default to MassAssignment.
This undoes the entire point of having put attr_acce...
2006 Jan 12
9
Scaffold shows all attributes altough I use attr_accessible!
Hi all
I have a Model like this:
class Member < ActiveRecord::Base
attr_accessible :username, :email, :first_name, :last_name
end
I have created a scaffold using script/generate scaffold member members
Using the URL localhost:3000/members/edit/1 I can edit all attributes,
including created_at, lock_version etc.! But it should only show the
attributes I listed in attr_accessib...
2005 Oct 14
1
Diff between attr_accessible and attr_accessor
I''m going though the paper back edition of agile development with Rails. On
page #128 I encountered following lines of code:
attr_accessor :password
attr_accessible :name,:password
What''s the difference between attr_accessor and attr_accessible?
-=- Neeraj
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
2007 Oct 16
12
Example for attr_accessible?
Is anyone out there writing specs to check attr_accessible fields? I had
originally written my spec to check for allowing the desired fields, and
then none of the other regular db fields. Unfortunately this isn''t
satisfactory, because attr_protected could have been used instead, which
of course wouldn''t prevent mass assignment to any what...
2010 Nov 02
7
Testing attr_accessible (and/or attr_protected)
I''ve been puzzling over how to test that attr_accessible has been set
for the correct columns; but the tests I''ve come up with so far seem
to fail to fail when I expect. I came across this old message from
this list:
http://www.mail-archive.com/rspec-users at rubyforge.org/msg01570.html
Which seemed like a plausible example, but my attempt (mo...
2009 Nov 27
2
attr_accessible & attr_accessor - what's the difference?
i''m still new to rails and working on digesting everything i come
across. recently i came across these two. what is the difference
between attr_accessor and attr_accessible?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/...
2012 Apr 27
1
Can't mass-assign protected attributes even if I use attr_accessible
...ts) I get the following error :
<h1>
ActiveModel::MassAssignmentSecurity::Error in
PostsController#create
</h1>
<pre>Can''t mass-assign protected attributes: name</pre>
I did lots of searches on the topic but I found no working solution :-(
I use attr_accessible to avoid MassAssignent errors and it works for all
others models but not for the "Author" name attribute.
Here is the Author model :
class Author < ActiveRecord::Base
attr_accessible :name, :email
extend FriendlyId
friendly_id :name, use: :slugged
# some...
2009 Nov 22
2
WARNING: Can't mass-assign these protected attributes: active
Hi,
I''m trying to understand this error:
WARNING: Can''t mass-assign these protected attributes: active
I had this error before when creating a record.I did not mark the attibutes
posted from the form as attr_accessible, so when the following line tries to
execute it throwed an Warning in the log, and the record was not saved.
@user = User.new(params[:user])
I find out that I have to have the attributes that I want to sent from the
form marked as attr_accessible. But now I''m not understanding the same e...
2008 Dec 28
0
:attr_accessible to protect all attributes
Hi,
I would like to protect all the attributes of one of my model. This
ticket talks about this issue: http://dev.rubyonrails.org/ticket/9631 ,
and a patch to the documentation was submitted:
http://dev.rubyonrails.org/changeset/8032 , which actually states that
defining :attr_accessible alone, means all attributes are protected.
However when I look at the rails API page for attr_accessible, I can''t
find the documentation about that:
http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001981
As of Rails 2.2.2, how do I protect all attributes of my model?
Best re...
2012 Oct 11
4
what;s the right url in this case
Hello,
I have this models
class Berichten < ActiveRecord::Base
attr_accessible :bericht, :user
belongs_to :user
belongs_to :Category
end
class User < ActiveRecord::Base
attr_accessible :email, :name
has_many :berichten
end
class Category < ActiveRecord::Base
attr_accessible :id :name
has_many :berichten
end
What I wonder is what the right url is when I wa...
2011 May 20
3
How to handle non model data in form?
...= f.text_field :text
.field
= f.label :author_id
%br
= f.text_field :author_id
.actions
= f.submit
But since I don''t want anyone to type in an author id I changed it to:
.field
= f.label :author_name
%br
= f.text_field :author_name
added to article.rb:
attr_accessible :author_name
def before_validation
if self.author_name
author_name = self.author_name.split
self.author =
Author.find_or_create_by_firstname_and_lastname(author_name[0],
author_name[1])
end
But now this line:
@article = Article.new(params[:article])
throws this error:
unknown attribute: autho...
2013 Mar 04
2
accepts_nested_attributes: undefined method 'association'_attributes
I have 2 models Timesheet and TimeEntry:
class Timesheet < ActiveRecord::Base
attr_accessible :status, :user_id, :time_entries_attributes
has_many :time_entries, dependent: :destroy
accepts_nested_attributes_for :time_entries, :reject_if => proc {
|attributes| attributes[''worktime''].blank? }
end
class TimeEntry < ActiveRecord::Base
attr_accessible :task_id, :...
2006 May 16
1
ActionMailer w/o database link (e.g., feedback form)
Hey,
A total noobieQ. Apologies, still learning.
Could anyone point me to examples of a non-database-driven feedback
form, for instance, a simple e-mail feedback form that takes advantage
of ActionMailer? (How do I carry a POST through to a ''def'' w/o a
database connection?)
Thanks!
--
Posted via http://www.ruby-forum.com/.
2008 Aug 31
0
attr_accessible & site administrator issue
...ers and Groups
tables. The attribute enables a site admin to set records to a
:featured_at datetime. There''s named spaced admin controllers for the
Users and Groups. The problem is, to set the :featured_at in the admin
controllers for users and groups, the attribute had to be exposed under
attr_accessible in User.rb and Group.rb. This means we''re open to mass
assignment hacks on this attribute. Is there a more elegant route to
avoiding hacks than setting the params[:user][:featured_at] = nil (same
for groups) in the public facing controllers for :create and :update
actions?
--
Posted via h...
2009 Jun 21
1
cannot do mass_assignment when inherited class ?
I got the following error when trying to create the elibrary instance
(rdb:21) @elibrary = Elibrary.new(params[:elibrary])
RuntimeError Exception: Declare either attr_protected or
attr_accessible for Elibrary, but not both.
params : "elibrary"=>{"title"=>"bingo three",
"short_description"=>"something new", "description"=>"<p>fsdfgdsg</
p>"}
Elibrary is declared as inherited from MediaItem, a...
2012 Apr 13
0
Scoped attr_accessible not working?
...ClassMethods.html>for this.
I''m on Rails3.2.3/Ruby1.9.3 and trying to use that technique in the
controller as described. It is supposed to dynamically restrict the
attributes that can be mass assigned. However, sanitize_for_mass_assignment
is ignoring the scope and using the default attr_accessible instead.
Is anyone else seeing this problem? Or has anyone successfully implemented
it the way the docs describe? Seems like it''s not working as advertised.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this...
2010 Jan 21
2
nested forms and attr_accessable
Rails 2.3.5
I am working on a nested form that assigns roles to users through a
table called clearances. I have attr_acessable turned off globally in
an initializer:
ActiveRecord::Base.send(:attr_accessible, nil)
I have this set in clearance.rb
attr_accessible(:description,
:effective_from,
:role_id,
:superceded_after,
:user_id)
And this is what params looks like after the submit button is
selected:
{"user"=>{"id"=>"146"}, "commit"=&g...
2012 May 04
3
Database schema question
...t they select or input are coming up.
Occasions will be selected from a checkbox type list or alternatively
manually input by the user (name and date of the occasion).
Users can have_many occassions.
How would i set this up in my models? So far i have:
class Reminder < ActiveRecord::Base
attr_accessible :date, :name
belongs_to :user
end
class User < ActiveRecord::Base
attr_accessible :address, :birthday, :city, :email, :gender, :interests,
:name, :postal_code
has_many :reminders
end
Thanks!
--
You received this message because you are subscribed to the Google Groups "Ruby on Ra...