Displaying 20 results from an estimated 40 matches for "attr_nam".
Did you mean:
attr_name
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...
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_con...
2006 Sep 04
2
"include" versus "extend" - what's the difference
..._attributes
self.attributes.keys.select { |k|
!self.class.non_audited_columns.include?(k) }
end
# If called with no parameters, gets whether the current model
has changed.
# If called with a single parameter, gets whether the parameter
has changed.
def changed?(attr_name = nil)
attr_name.nil? ?
(@changed_attributes && @changed_attributes.length > 0) :
(@changed_attributes &&
@changed_attributes.include?(attr_name.to_s))
end
# Executes the block with the auditing callbacks disabled.
#
#...
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....
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_...
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
...intf (stderr, "encoding_recommendation: Non-printable character found at data index %zu (c=%i)\n", i, data[i]);
+ break;
+ }
+ }
+
+ return is_printable ? "none" : "base64";
+}
+
+static int
+safe_print_string_attribute (hive_h *h, void *writer_v, const char *attr_name, const char *attr_encoding, const char *attr_data)
+{
+ int ret = 0;
+ char *encoding_to_use = NULL;
+ if (attr_name && attr_data && attr_encoding) {
+ xmlTextWriterPtr writer = (xmlTextWriterPtr) writer_v;
+ encoding_to_use = encoding_recommendation (attr_data);
+
+ if...
2006 Dec 12
2
RXML partial question
...ns_display'',
:layout => false,
:locals => {:parent_xml => xml,
:buttons => buttons,
:obj => obj}) if buttons_first
========== snippet of RXML partial ================
columns.each do |col_array|
attr_name = col_array[0]
column_display_name = col_array[1]
value = eval("obj.#{attr_name}")
column_contents = (column_display_name == ''Fax Number'' ?
number_to_phone(value, {:area_code => true}) :
value)
parent_xml.td(colum...
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?)
...cross 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 not null,
primary key (for_table, foreign_id, language_id)
);
Notice the for_table and foreign_id columns. These two are used to
identify the table and row to which each record belongs.
To make this work I then add something like this to each models that nee...
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_connecti...
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 '...
2007 Aug 18
0
RSpec and acts_as_attachment
...h''
vendor/plugins/acts_as_attachment/lib/technoweenie/acts_as_attachment/
instance_methods.rb:152 :in `attachment_attributes_valid?''
./spec/models/../spec_helper.rb:635 :in `create_user_file''
./spec/models/user_file_spec.rb:11
152 [:size, :content_type].each do |attr_name|
153 enum = attachment_options[attr_name]
154 errors.add attr_name,
ActiveRecord::Errors.default_error_messages[:inclusion] unless
enum.nil? || enum.include?(send(attr_name))
155 end
156 end
---
David Rice
http://www.davidjrice.co.uk
-------------- ne...
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,