similar to: ActiveRecord attributes -- strange behavior when adding Array to an element

Displaying 20 results from an estimated 1000 matches similar to: "ActiveRecord attributes -- strange behavior when adding Array to an element"

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
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
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/.
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)
2008 Dec 20
9
Upgrade to Rails 2 - problem with "save" (MySQL boolean issue?)
I have been working through an upgrade of my 1.2.6 application to 2.2.2. I am almost there but I have hit a problem with ActiveRecord. Before the upgrade, the following code was working fine. def create_root(administrator) root = create_root_collection(self.pingee_name, administrator,
2006 Jan 30
1
how to get column_for_attribute?
Hi all, In the code below I don''t understand: 1. Why I have to prepend overriden method content_columns with "self." to get it working? 2. Why column_for_attribute method is not working (no such method?) even if SomeTable is subclass of ActiveRecord::Base which have public column_for_attribute method? > class SomeTable < ActiveRecord::Base > > def
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
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,
2006 Feb 06
7
Delaying initialization of associations until first access
Guys, Say I have the following: ----- class Person < ActiveRecord::Base has_one :house end class House < ActiveRecord::Base belongs_to :person attr_accessor :color end ----- Then I have the following code: ----- john = Person.new john.house.color = "Blue" john.save ----- What I would like to have happen, is that on first call to john.house, if house hadn''t been
2007 Feb 18
2
SerializationTypeMismatch in Production Mode
In production mode, I keep getting this error the 2nd time it loads a page with a serialized attribute: ActiveRecord::SerializationTypeMismatch (answers_container was supposed to be a Array, but was a NilClass): /vendor/rails/activerecord/lib/active_record/base.rb:1964:in `unserialize_attribute'' In development, it works fine. In fact, if I set to false config.cache_classes in
2006 Feb 19
2
possible rails -> postgresql bug
Hi I have a problem accessing an array field in a Postgresql database. Here is the table definition. View "neil.flashing_codes" Column | Type | Modifiers -------------+-----------------------+----------- code | character varying(10) | description | text | folds | integer[] | View definition: SELECT
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 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
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
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 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,
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 Jan 19
2
Easy way to handle form input without a model class?
I have a couple forms that I''d like to be able to validate and automatically populate, but it shouldn''t be based on AR. In fact I often have a bunch of small forms that I can''t really justify writing a whole new model class for anyway. I''d like to validate the form input, and then use rails helpers to automatically populate the form if validations fail.
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
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