search for: attr_names

Displaying 20 results from an estimated 40 matches for "attr_names".

2008 Mar 18
0
Major issues with ActiveRecord callbacks in BackgroundRb r324
Hi there I''ve been running BackgroundRb in production for a few months now. Recently we added encryption onto some of our ActiveRecord fields by hooking in the before_save and after_save callbacks, like: class MyCallback def initialize(attr_names) @attr_names = attr_names end def before_save(model) @attr_names.each do |attr_name| next if model.send("#{attr_name}").blank? model.send("#{attr_name}=", Encrypter.encrypt(model.send("#{attr_name}"))) end end def af...
2005 Dec 16
4
Validation with Aggregation
ActiveRecord supports composed_of for value objects which is fantastic but one thing that it doesn''t seem to support (or at least I am unable to find any documentation for) validation of the value objects. For example, given the following: class Message < ActiveRecord::Base composed_of :sender, :class_name => ''EmailAddress'' composed_of :recipient,
2005 Apr 08
2
attr_names in test67
Hello, I'm wondering if the following situation is valid (though I think it isn't since I still cannot authenticate with ldap pass/userdb on test67 running on FreeBSD-5.3). Is it normal that the passdb_ldap_conn->attr_names second element (for instance) "turns to" "homeDirectory" as the following step by step gdb run sample shows ? : -- Breakpoint 1, userdb_ldap_preinit (args=0x80796d0 "/usr/local/dovecot/etc/dovecot-ldap.conf") at userdb-ldap.c:201 201 userdb_ldap_conn...
2006 Sep 04
2
"include" versus "extend" - what's the difference
Hi, Just wondering when one would use "include" over "extend"? Both seem to bring in methods to the class no? The context is I''m just trying to understand why both are used with the acts_as_audited plugin: Full extract from plugin (used within here): ================================================== # Copyright (c) 2006 Brandon Keepers # # Permission is hereby
2006 May 18
1
Introspection of validates_presence_of
Hello all. I don''t know how to get all symbols passed to method validates_presence_of in model. I''ve trying to use following solution: class News < ActiveRecord::Base validates_presence_of :title, :text def validates_presence_of(*attr_names) @@obligatory_fields = attr_names ActiveRecord::Base.validates_presence_of(*attr_names) end def obligatory_fields @@obligatory_fields end end But when object news was created i''ve got following error message: uninitialized class variable @@obligatory_fields in News. I...
2006 Apr 12
0
Netmask validator
Sharing the wealth. I just finished working on a custom netmask validator and thought others might benefit. Of course, comments and suggestions are welcome. def validates_netmask(*attr_names) configuration = { :only_numbers => ''must only use numbers as octet values'', :range => ''has one or more octet values that are > 255'', :invalid => ''is invalid'' } configuration.update(attr_na...
2006 Jul 27
9
Introspecting validates_presence_of
Hello people, I''d like to detect whether an attribute of a model has vaildates_presence_of applied to it so I can automatically apply a mandatory (*) to the field...it doesn''t look easy...any ideas? Cheers, -- Dan Webb http://www.danwebb.net
2007 Mar 29
1
ActiveRecord attributes -- strange behavior when adding Array to an element
Hi, I have a database table and associated ActiveRecord model. I was trying to store (temporarily) an array in one of the attribute elements - not to save it, but just so that I can keep some form data in a sensible place. A stripped down version of the problem I''m having is: p = Property.new(:bedroom_count => ["2","3"]) puts p.inspect # ==> will correctly show
2007 Apr 27
3
attachment_fu content_type problem
Hi all.... Admittedly I''m new to Rails and trying to find my way but I''m having an issue with uploading documents with attachment_fu. I have a form where I''m uploading multiple attachments (using AJAX to add file_filed_tags). That seems to work pretty well. The problem is I can''t seem to get the content_type to work as I would expect. For example, if I use
2006 Apr 17
5
Finding out updated fields
Hi, When we update a record via an update form, is there an easy way to find out the fields that have been changed. If the update is successful, i want to display: The following fields have been changed: field-name = new-value ... Thanks, Lantis. -- Posted via http://www.ruby-forum.com/.
2011 Sep 17
3
[PATCH 1/1] hivexml: Base64-encode non-printable data
Some of the data in names and string values were being unsafely printed, causing some types of XML processors to fail (e.g. Python's Expat). This patch checks for printability of each character and outputs base64 with an encoding attribute for unsafe data. --- xml/hivexml.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 64 insertions(+), 11 deletions(-)
2006 Dec 12
2
RXML partial question
All, I have a RXML template which renders partial RXML templates within it. A snippet is below. The "xml" variable is the parent template''s Builder variable. It is passed into the partial under the name "parent_xml". Why can''t I use :locals => {.... :xml => xml ....} in my call to render the partial? It seems like if I do use :xml => xml, it
2006 Jul 07
5
link_to: link is missing id
I''m using a legacy table, where the unique id is not ''id'' I have a Model class like the following: class Article < ActiveRecord::Base set_primary_key "ARTICLE_ID" end however, using a link_to like the following (modified scaffolding), the link has no id value: <% for article in @articles %> <tr> <% for column in
2005 Dec 30
5
HABTM with finder_sql problem (Rails bug?)
I''m building an app that needs i18n support across the entire database (i.e. localized attributes). In order to do this I''ve created a special HABTM join table that can be associated with _any_ other table: create table language_strings ( for_table varchar(255) not null, foreign_id int not null, language_id varchar(5) not null, attr_name varchar(255) not null, value text
2006 Jun 13
6
Dead horse: validates_associated
Regarding validates_associated... Let''s say I have: article belongs_to author But for whatever reason, I want an article to also be written anonymously and therefore not require an author. Then I have: Article: belongs_to :author validates_associated :author But I DON''T have validates_presence_of. What I want to do is validate that an author is valid --if it is
2005 Apr 12
1
test67 ldap_connection
...c: line 122 (handle_request): assertion failed: (scheme != NULL) dovecot: Apr 12 18:22:42 Error: child 43147 (auth) killed with signal 6 -- ] I've noticed the following changes in the source code, and my understanding (which may be wrong) of my problem goes as follows : - In test62, the 'attr_names' attribute array was defined outside the 'ldap_connection' struct, thus allowing 'passdb_ldap_conn' and 'userdb_ldap_conn' structs to have different array of such type. - At the opposite, in test67, the 'attr_names' array is inside the 'ldap_connection...
2012 Nov 08
1
validates_uniqueness_of(*attr_names) w scope not working in unit test
Rails 3.2.8 Very strange , it works in dv mode console , but not in a unit test class User < ActiveRecord::Base belongs_to :subdomain validates_uniqueness_of :email, :scope => :subdomain_id class UserTest < ActiveSupport::TestCase def initialize_user @booboo = FactoryGirl.create(:subdomain, name: "booboo") @coocoo = FactoryGirl.create(:subdomain, name:
2005 Mar 30
2
test65 killed by SIGSEV
...led with signal 11 To be precise, the problem occurs in the "ldap_lookup_pass" function (auth/passdb-ldap.c) just before loging the ldap request parameters (auth_request_log_debug) and to actually perform the search (db_ldap_search). The signal occurs on the call of t_strarray_join(attr_names, ",") What I'm observing is that the "attr_names" array of the "passdb_ldap_conn" ldap connection doesn't seem to hold the right attributes : while in the test62 version it holded 'uid' and 'userPassword', it holds now 'uid' and 'ho...
2007 Aug 18
0
RSpec and acts_as_attachment
Hey guys, I''m getting a weird error when trying to test something like the following. It''s a model that is using acts_as_attachment but the weird thing is the equivalent Test::Unit case passes. Does anyone have any ideas? Best, Dave # it was a Test::Unit case first def test_should_be_invalid_without_file UserFile.any_instance.expects(:with_image).never
2006 Jun 01
1
Automatted Getter/Setter
Hey.. So I have a model that has a lot of number fields. Each of these go through a process when read in and read out to add/remove commas (between every three numbers) to make them more readable. The getter I currently have is like this: def sale_price Listing.insert_commas(read_attribte (:sale_price)) end and the setter is: def sale_price=(price) write_attribute(:saleprice,