Displaying 20 results from an estimated 3000 matches similar to: "A real puzzler: attr_accessor / create incompatibility?"
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
2007 Dec 04
10
Unexpected message on :attr_accessor
This may be a dumb noob issue, but I haven''t found any answers while seaching
the forum--
I have a controller method
def edit
@user = User.find params[:id]
@user.password_confirmation = @user.password
end
The User class has an "attr_accessor :password_confirmation" definition (so
"password_confirmation" doesn''t exist in the users table). My spec
2007 Mar 14
3
A place to put common partial templates and RJS files?
Greetings,
I have a partial template file (acutally, it is an RJS file but the
same principle is in question here) which I wish to "share" between
multiple controllers. Does anyone know where in the directory tree I
would put these files in order that I can access them from multiple
controllers in the same app? I really would prefer not having to copy
them all into all of the
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 "Ruby on Rails:
2006 Jul 27
5
Calculate methods on attr_accessor objects
Is it possible to use the calculate methods (sum, etc.) on attr_accessor
attributes?
Ie:
Class Item < ActiveRecord::Base
attr_accessor :total_cost
def total_cost
@total_cost = self.cost_unit * self.amount
end
calling Item.sum(:total_cost) or Item.sum(''total_cost'') both return a
unknown column ''total_cost'' mysql error.
I thought that active
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
2008 Jun 24
1
cache issue with attr_accessor field
Hi,
I''ve got a model with the following attribute added:
attr_accessor :level
which does not exist in the database. After putting instances of this
model in the cache (using Rails.cache.fetch(''foo'') { Category.all } ),
when I retrieve it back from the cache, then trying to access .level
gives:
undefined method `level'' for #<Category:0x34d50a0>
2006 Nov 04
2
Possible to use attr_reader/writer in model?
I have some properties that I want setable externally, but readable only
internally. I''ve played around with attr_writer (and attr_reader
separately) but can''t figure out how to get either to work. I can do
what I want using attr_accessor, or just straight out defining the prop
setter method. Anybody know how to use attr_writer or attr_reader with a
model?
You da man,
Joe
2009 Sep 09
4
undefined method `attr_accessor' for #<CustomersControl
pleas help
--
Posted via http://www.ruby-forum.com/.
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
2006 Mar 31
1
dumb question: what is attr_xxxx
i''m very new to the rails scene and am seeing lines of code like
attr_reader, attr_writer, attr_accessor, etc... and have no idea what
they do. reading the section in the book i''m reading that explains the
previous block of code says nothing about it really.
--
Posted via http://www.ruby-forum.com/.
2006 Apr 03
7
Getters and setters problem?
Hi list,
first evening of playing with rails, so please forgive me if I ask
something stupid. ;-)
I created a User model and tried to use ActiveRecord callbacks to
convert the password to sha1 just before saving it. For some reason
postgresql gives me a error because the given password is null. To
test even further I tried to change :login too, same error happens,
:login is empty too.
I am sure
2006 Jun 07
2
Problem with a setter that converts euros to cents
Hi,
I have some problems with an application where I''m using custom
accessors to do currency conversions. In my model, I have a price
attribute in the database that stores the value in cents, to avoid
future problems with float arithmetic and round. But at the views, I
would like to show the price in euros, with decimal for the cents. So
I defined a new attribute called price_in_euros,
2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come
in. Console just gives me back :account_id => nil. Obviously I''m trying to
set it though. Silly console...
But, I can set the account_id column in my controller like so:
@user = User.new(params[:user])
@user.account_id = account.id
@user.save
Here''s what I give to the controller:
User.create :name
2006 Feb 05
3
attr_accessor help understanding
i''m having trouble understanding the attr_accessor and attr_accessible
syntax in models. I''m workink through the Agile book and even a look at
the ruby doc does not really help to clarify.
Thanks aftershock
--
Posted via http://www.ruby-forum.com/.
2006 Jan 06
2
Re: Some advice on DB modeling
I have more or less the same problem. I''m trying to build a system where
users can enter their friends. But the solutions seems not to work for me.
I used same sql:
CREATE TABLE `friends` (
`user_id` int(11) NOT NULL default ''0'',
`friend_id` int(11) NOT NULL default ''0'',
KEY `user_id` (`user_id`),
KEY `friend_id` (`friend_id`),
2007 Feb 22
0
Fwd: Net groupmap list puzzler
Hi,
I think at first you have to do a net groupmap add all the well known Groups.
System Operators (S-1-5-32-549) -> -1
Replicators (S-1-5-32-552) -> -1
Guests (S-1-5-32-546) -> -1
Domain Users (S-1-5-21-3732367786-856876144-3282938955-513) -> -1
Domain Admins (S-1-5-21-3732367786-856876144-3282938955-512) -> -1
Power Users (S-1-5-32-547) -> -1
Domain Guests
2001 Apr 07
2
A programming puzzler
I am trying to replicate part of the function of the
S-Plus terms.inner function. I don't need an entire
model terms object but R expressions or character
strings containing the innermost variable name given
a vector of character strings or expressions. Here
are some example inputs that each should result in the
string or expression "x":
x; x^2; g(x); h(g(x)); h(g(x^3));
2006 Sep 05
5
cattr_accessor
Hi,
i''ve been playing with ror for a little over two months now, and was
wondering wether someone could explain to me what was
cattr_accessor
and if it is still in use. . . i looked up in api.rubyonrails.com and
coulnd''t find any documentation...
is it a useful/worth learning method? what do u use it for?
--
Posted via http://www.ruby-forum.com/.
2006 May 09
1
Session mgmt. bug - ActiveRecord & MemoryStore session store
Windows XP Pro
Rails 1.1.2
I need some help verifying this behavior that I''m seeing.
BUG: Objects in session which are descendants of ActiveRecord::Base lose
attributes on subsequent requests when using CGI::Session::MemoryStore.
TO REPRODUCE:
0) Set up MemoryStore as the session database manager in the appropriate
environment.rb file in config
1) Create a model object X that