Displaying 20 results from an estimated 1000 matches similar to: "Calculate methods on attr_accessor objects"
2007 Mar 21
2
A real puzzler: attr_accessor / create incompatibility?
Greetings,
I have a problem with attr_accessor and create seemingly being at odds
with each other in my environment. Here is the setup:
A simple class representing a US State (say, Maine for example):
class State < ActiveRecord::Base
attr_accessor(:name, :code)
end
In an IRB session, I type the following and receive the response
included below:
>>
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:
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
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
2006 May 19
2
How to run direct DML (insert or update)
I want when the user clicks on a button on the browser
"Perform monthly billing run" the controller to lanch a sql DML
statment to be called (in the model?) than runs something like
"insert into billing (item, qnt, total_cost, billing_run_timestamp
select item, qnt, item*cost as total_cost, timestamp
from services
where service_end_date is null"
How can I run a DML
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>
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
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 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`),
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
2011 Jan 17
4
Factory Girl and attr_accessor with validation
I have a problem with a recent change to one of my models when created
via Factory.create.
class User < ActiveRecord::Base
attr_accessor :tc_check
validates :tc_check, :presence => true, :acceptance => true
...
end
The following definition fails, when calling
Factory.create(:valid_user)
Factory.define :valid_user, :class => User do |u|
u.email
2006 Aug 11
2
Accessing belongs_to objects from a form_for context
In a form_for context, is there a way to access objects that are related
to the primary object with a belongs_to? I think an example will serve
best:
class User < ActiveRecord::Base
belongs_to :person
attr_accessor :username
end
class Person < ActiveRecord::Base
has_one :user
attr_accessor :first_name
end
<% form_for :user do |form| %>
<%= form.text_field
2007 Apr 28
3
Learning ruby question
I''m having trouble understanding Ruby''s concept of scope. Could
someone explain the difference between the following 2 programs.
They both return the same output "aaaaaaaa", but I''m just not sure
about self in #1. Is self.day and self.title referring to and setting
class variables or are they instance variables? Thanks in advance.
# 1.
class Session
2010 Aug 13
2
Rails 3 / ActiveModel for Credit Card information?
When submitting billing information in the past I''ve always used
attr_accessor for credit card details as they should not be saved in
the database. In addition I always end up storing the card
expiration date so that the date form helper works correctly.
With Active Model it seems logical to create a CreditCard class to
hold this data instead.
**1st issue.**
It seems there still
2011 Jan 08
4
Help How to create DSL for conditional validations
Hi All,
I am new to Ruby and ROR
I were trying to create small DSL for conditional validations
valid_with_cond :bypass_validation do
if self.addresses > 3
errors[:base] << "Can not have more than 3 addresses".
end
end
By this I wanted to create array of method and call them all in custom
validation method.
this above code I wanted to do
attr_accessor
2007 Sep 23
9
Code reviews: my dumb use of acts_as_commentable (newbie)
With the help of several heroes here yesterday I beat my way into a
working solution to adding comments to one or more models in my
application using acts_as_comentable. Great plugin, but my
implementation is lame. I need enlightenment.
I have users who log in. For several views I want to let them add
comments. Enter act_as_commentable which does just this -- it''s
polymorphic, so you
2009 May 25
1
Help --- My phone number field saves blank
I have a phone field in my table.
But in my form i have two text boxes to get the phone number and the
country code like below
Enter country code ----- Enter phone code ------
In my table i have to save the phone code field after joining the above
values with "-" symbol.
Example => 0225-25874255
I dont have table field for country_code .
So i created like below
attr_accessor
2006 Apr 21
3
Conceptual q about rails
Classes like activerecord, etc contains strange elements like
''belongs_to :something'', ''has_many :smth'' etc.. what is it? I can''t find
them in ruby lang documentation.. it''s similar to ''attr_accessor'' and
other costructions, how I can create my own constructions and how I must
understand them? Could anyone give me some links