search for: read_attribute

Displaying 20 results from an estimated 94 matches for "read_attribute".

2006 Feb 06
7
Delaying initialization of associations until first access
...hose empty House records in the database is a lot of waste. I''ve tried variations on the below code, each of which has failed to work. It *seemed* to work, but it doesn''t persist to the database properly: class Person < ActiveRecord::Base has_one :house def house if !read_attribute(:house) h = House.new h.save write_attribute(:house, h) end read_attribute(:house) end end Can anyone tell me the proper way to accomplish this behavior? Thanks! John
2006 May 10
13
Issue in ActiveRecord generated reader methods
Hi all! I have come into a strange issue in Rails that I am hoping someone can shed some light. To make a very long story short, I have been researching how to override ActiveRecord::Base#read_attribute and write_attribute to perform security checks at the model level (influenced by the ModelSecurity generator). Shortly after implementing some code to check this behavior, I began to see undefined behavior from rails. The first request to read an attribute would be denied correctly, how...
2006 Jun 21
8
Modifying Model Output
Hi! I''m a very-very new Ruby-on-Rails user even if I have some experience with other Languages (mostly PHP, so this is my first real object-oriented language) My problem, newbie-ish as it is, is the following: I have a model, Article, that returns Articles from the DB. Now, when a certain field of the model (the intro text) contains no data, I want to fill it with a truncated
2016 Nov 30
1
slow directory access, convert_string_internal: Conversion error: Incomplete multibyte sequence
...but can't. Solaris ZFS file systems supports ACL's similar to windows in the sense that not limited to a single user and single group. # ls -lvd /Pool1/Department/Sales drwxrwx---+ 13 jsmith sales 48 Nov 29 18:58 /Pool1/Department/Sales 0:user:nobody:read_xattr/read_attributes/read_acl:allow 1:user:root:read_xattr/read_attributes/read_acl:allow 2:group@:list_directory/read_data/add_file/write_data/add_subdirectory /append_data/read_xattr/write_xattr/execute/delete_child /read_attributes/write_attributes/delete/read_acl/write_acl /write_owner/synchronize:...
2010 Jul 19
3
ActiveRecord override
...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 removed once all data is encrypted begin return Crypto.decrypt(self.encryption_key, read_attribute(:borrower_ssn)) if read_attribute(:borrower_ssn) && self.encryption_key rescue return read_attribute(:borrower_ssn) if read_attribute(:borrower_ssn) && self.encryption_key end nil end end However, when I do Person.find(27) I get: #<Person id: 27, ssn: "...
2016 Nov 30
2
slow directory access, convert_string_internal: Conversion error: Incomplete multibyte sequence
There are definitely some files with some weird names- in an ssh session they don't even have regular characters. e.g -rw-rw---- 1 xxx xxx 114985112 Oct 31 14:39 ▒^t Not sure if that is related to problems though. The top command shows Memory: 12G phys mem, 343M free mem, 2048M total swap, 2048M free swap This is in the evening so should not be much load but I think
2006 May 09
11
model filter?
Hi All, Is there a way to filter / modify the output of a model class before it''s returned to controller/view that''s calling it? Example: I have a field phone_number which I always want to preformat using the number_to_phone() helper.... Any help is appriciated. Thanks! -- Posted via http://www.ruby-forum.com/.
2006 Jul 02
7
How can I intercept attribute calls?
Hi. I have two types of fields in my database, e.g. "name" and "name_ru". First one is a user''s name in english and the second one is in russian. I want to intercept calls like "c.name" and add "_ru" to it if current language is russian (I have my own Locale class like n Globalize). So I want such thing: -- Locale.set("en-US") c.name
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) raise ''You made it!'' end en...
2008 Feb 28
0
Windows permissions and inheritance
...nd under Solaris it looks ok too, the permissions appear as: d---r-x---+ 3 ross smith domain users 3 Feb 28 08:24 Departments 0:group:domain admins:list_directory/read_data/add_file/write_data /add_subdirectory/append_data/read_xattr/write_xattr/execute /delete_child/read_attributes/write_attributes/delete/read_acl /write_acl/write_owner/synchronize:file_inherit/dir_inherit:allow 1:group@:list_directory/read_data/read_xattr/execute/read_attributes /read_acl/synchronize:file_inherit/dir_inherit:allow However, if I logon to a windows machine as a Domain Admin, and...
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
2007 Dec 15
2
Reading Model data before update
Hi all, here is the challenge: I have this validation method, that basically prevents an object which billed = true to be updated: def before_update if read_attribute(:billed) errors.add_to_base(''This service has already been billed for'') end !read_attribute(:billed) end The above code does not work in case I do something like: object = Model.find(:first) object.billed = true object.save because in my before_update filter I a...
2005 Nov 23
14
ACL issues with ZFS
ZFS introduces a new and incompatible ACL interface into Solaris and this seems to be not yet fully completed in addition to the fact that is causes a lot of problems for software that needs to be compatible with Solaris-2.5 like star. Proof for incompatibility: create a file on UFS and set an ACL for this file. Use Sun tar cpf out file to archive this file. Unpack this archive file on ZFS
2010 Jan 31
0
? NFSv4 and ZFS: removing write_owner attribute does not stop a user changing file group ownership
...othing for everyone. bash-3.00$ id uid=100(timt) gid=10001(ccbcadmins) bash-3.00$ groups ccbcadmins staff bash-3.00$ ls -v testacl -rwxrwx---+ 1 timt ccbcadmins 0 Jan 31 16:24 testacl 0:owner@:read_data/write_data/append_data/read_xattr/write_xattr/execute /delete_child/read_attributes/write_attributes/delete/read_acl /write_acl/write_owner/synchronize:allow 1:group@:read_data/write_data/append_data/read_xattr/write_xattr/execute /delete_child/read_attributes/write_attributes/delete/read_acl /write_acl/write_owner/synchronize:allow I can cha...
2006 Aug 19
5
Form helpers don''t work with facade columns?
...39;'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 read_attribute(:price)/100.00 end end and for the most part that works great, I can call product.price and get 9.99, I call product.price=9.99 and it gets stored in the DB as 999. However, when I use the form helpers in the views.... <%= text_field ''product'', ''price''...
2009 Nov 09
3
How can I improve a Ruby on Rails code that hast a lot of SQL as strings?
...all_votes.voteable_type = "Item" # LEFT JOIN votes as user_votes ON # user_votes.voteable_id = items.id and # user_votes.user_id = 2 and # user_votes.voteable_type = "Item" # GROUP BY items.id # ORDER BY score DESC end def score s = read_attribute("score") if s == nil votes.sum :value else Integer(s) end end def user_vote(user_id) if Integer(read_attribute("voter_id")) == user_id Integer(read_attribute("user_vote")) else vote = votes.find(:first, :conditions =>...
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 old_field_name field_name def field_name #do something old_field_name end This works, but is there a buil...
2004 Nov 22
0
Can''t set then read id on AR class in 0.8.5
...saving them when the end tag is reached. This means that child elements get saved before the parent. When the child element is created it''s belongs_to relationship is set to the parent object. I came across a problem when upgrading from 0.8.0 to 0.8.5, which changed: def id read_attribute(self.class.primary_key) end to def id read_attribute(self.class.primary_key) unless new_record? end (Ticket 187) As the parent record hasn''t been saved yet, when I call #save on the child it can''t get the ID of the parent to insert into the foreign ke...
2014 Feb 20
0
Solaris Extended ACLs samba-3.6 vs samba-4.1 differences
...except for the write_acl part. It looks like this: chown root username chmod A- username chmod og-rwx username chmod A+user:username:write_acl:deny username chmod A+user:username:list_directory/read_data/add_file/write_data/add_subdirectory/append_data/read_xattr/write_xattr/execute/delete_child/read_attributes/read_acl/write_owner/synchronize:allow username chmod A+group@:read_xattr/read_attributes/read_acl/synchronize:allow username chmod A+everyone@:read_xattr/read_attributes/read_acl/synchronize:allow username This all works very well when using an NFS mounted filesystem, and works with samba-3.6.22...
2006 Jul 13
4
Does text_field go directly to attributes hash in AR object?
...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 sprintf("(%d)%d-%d", fax[0,3], fax[3,3], fax[6,4]) "crap" end Here''s a snippet of my template: <TD><%= @current_job.FAX %><%= text_field(:current_job, ''FAX'') %></TD> Fax: crap[text field with num...