similar to: Rewriting attribute accessors?

Displaying 20 results from an estimated 3000 matches similar to: "Rewriting attribute accessors?"

2006 Aug 19
5
Form helpers don''t work with facade columns?
Hello all, I''ve been trying to use a facade column but I notice that the form helpers don''t seem to respect the facade. In the following example I''m trying to story the prices as Integer values but present them to the user as decimals. class Product < ActiveRecord::Base def price=(new_price) write_attribute(:price, Float(new_price)*100) end def price
2006 Aug 01
0
Validation of facade columns
I''m having difficulty understanding how to make validation of facade columns consistent with validation of other active record columns. To illustrate this, I''m going to extend the facade column example discussed on pp. 284-5 of AWDR. Let''s say that there is a "rectangles" table that has width and height columns. For some unknown reason, width is stored in
2006 Jul 13
4
Does text_field go directly to attributes hash in AR object?
All, I''m having a hell of a time figuring out what is going on here. I''m trying to override one of my getters so that I can format it a certain way in my form. But I can''t seem to get text_field to call the appropriate method on my object. So here''s my getter: public def FAX fax = read_attribute(:FAX) puts fax
2006 Mar 02
6
Newb question about facade columns
Hello, I am trying to deal with a database table that contains a date in the form of the number of seconds since epoch. Data is inserted in this format by an existing script that I can''t change, so a schema change isn''t realistic. I would like to allow humans to view and edit this data in the form of an actual human-readable date. I figured a facade column would be the
2006 Jun 01
2
Hiding an attribute
I am using a smallint database column to store several boolean flags. The flags are accessible thru facade column accessors. I''d like to hide the database column so all access is thru the facade accessors. How do I do it? TIA, Jeffrey
2006 Jan 14
0
Overriding column accessors?
Hi, Is it possible to override the default accessors that are created by Rails? For instance I had this User object which has the column headings "password" and "salt" in its SQL table. I did manage to override the setter accessor for password by using def password=(new_password), but when I tried doing the same for the reader by using a def password method (to return a
2006 Feb 20
0
Override automatic accessor for reference field in model
When a column in a database table is actual data, rather than an fkey to another table, I can override the automatic accessor by just doing the following: def field_name # do something here read_attribute(field_name) end This does not seem to work for me if the field is an fkey, say user_id, linking to another table. I''ve made this work by aliasing the accessor like this: alias
2017 Aug 28
0
regex - optional part isn't considered in replacement with gsub
"Please, consider that some SKUs have "-" in the middle, for example: "PG-9021". Then you need to include these in the list of patterns you gave. Try it again -- this time with a **complete** list. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his
2017 Aug 27
6
regex - optional part isn't considered in replacement with gsub
Hello, I need some help with regex. I have this to sentences. I need to extract both "49MU6300" and "LE32S5970" and put them in a new colum "SKU". A) SMART TV UHD 49'' CURVO 49MU6300 B) SMART TV HD 32'' LE32S5970 DataFrame for testing: ecommerce <- data.frame(a = c(1,2), producto = c("SMART TV UHD 49'' CURVO 49MU6300",
2017 Aug 27
0
regex - optional part isn't considered in replacement with gsub
Omar: I don't think this can work. For example number-letter patterns 4), 5), and 6) would all be matched by pattern 6). As Jeff indicated, you need to provide the delimiters -- what characters come before and after the SKU patterns -- to be able to recognize them. In a quick look at the text file you attached, the delimiters appeared to be either "-" or " " (blank) and
2010 Jul 19
3
ActiveRecord override
Would really appreciate it if someone could tell me why this is happening: I override ssn method of AR class so I can encrypt/decrypt to/from the db: class Person < ActiveRecord::Base def ssn=(value) write_attribute(:borrower_ssn, Crypto.encrypt(self.encryption_key, value)) write_attribute(:borrower_ssn_final_four, value[5,4]) end def ssn # this begin - rescue can be
2006 Jan 02
3
Altering the accessor of an association collection
I want to be able to do something like this (for example): class Person < ActiveRecord::Base has_many :friends def friends(living_in = :uk) # filter based on parameters here end end Is there any way I can redefine the accessor for an association whilst still being able to get the values? Basically, I''m looking for an equivilent of read_attribute() for associations. --
2018 Sep 26
1
Which is the best open source ecommerce platform?
Good afternoon from Singapore, There are far too many choices when it comes to open source ecommerce solutions. Are there any credible rankings of open source ecommerce platforms? Which open source ecommerce solution do you think is the best and tell me why. Thank you. ===BEGIN SIGNATURE=== Turritopsis Dohrnii Teo En Ming's Academic Qualifications as at 30 Oct 2017 [1]
2006 Jul 14
7
Form validation - keepin correct fields displayed on refresh
All, I''m finally doing my first real form in Rails - the model object that I''m entering information for has 8 validations so far. If I type in good values for all the fields but one, I get the pretty validation, and the nice field highlighting, but all of the fields are cleared, forcing me to retype all of that info. That is a big drag. Is there a standard way to get the
2006 Jun 13
0
Best way to format attributes during visualization/editing
Hi to everyone, My name''s Carmine and I''m a rails newbie. So, here''s my newbie question :) I have a model with one attribute named "kind" of type integer. This attribute can assume values within the range [0..5]. Each value has a "verbose" representation e.g.: 0 => grain, 1 => liquid ... To visualize the verbose representation I''ve
2009 Sep 23
5
Overriding AR read/write_attribute - Overridden write_attribute Is Never Called
Could someone explain this? #config/initializers/ar_attributes.rb module ActiveRecord module AttributeMethods alias_method :ar_read_attribute, :read_attribute def read_attribute(attr_name) p "read_override" ar_read_attribute(attr_name) end alias_method :ar_write_attribute, :write_attribute def write_attribute(attr_name, value)
2005 Jul 05
2
root@localhost email problem
I have another problem with the email root at localhost not working now on centos 3.5 with plesk. This has always worked in the past. Anytime I test my ecommerce store the default email address has been root at localhost and has sent an email to my domain email address when testing. Just recently this has stopped working. The ecommerce store is php. I contacted the ecommerce store developer
2009 Jun 09
0
[LLVMdev] Regular Expressions
> On Tuesday 09 June 2009 04:35, Török Edwin wrote: > > On 2009-06-09 12:27, Howard Su wrote: > > > This change break the MSVC build since no regex by default in Windows > > > MSVC platform. > > > > Perhaps we should add a regex implementation to lib/System? > > That's potentially a lot of work. I started looking at it and it would > involve
2004 Nov 22
0
Can''t set then read id on AR class in 0.8.5
I''m learning rails and have a test application which parses parts an XML file to create AR objects and puts them in a database. The IDs in the database are taken from the XML, i.e. I explicitly set them using #id. The XML structure is mapped to AR relationships using has_many, belongs_to etc. I''m using a SAX parser, creating objects when the element start tag occurs and saving
2009 Jun 09
6
[LLVMdev] Regular Expressions
On Tuesday 09 June 2009 04:35, Török Edwin wrote: > On 2009-06-09 12:27, Howard Su wrote: > > This change break the MSVC build since no regex by default in Windows > > MSVC platform. > > Perhaps we should add a regex implementation to lib/System? That's potentially a lot of work. I started looking at it and it would involve hiding the OpenBSD library under some other