similar to: Can''t set then read id on AR class in 0.8.5

Displaying 20 results from an estimated 9000 matches similar to: "Can''t set then read id on AR class in 0.8.5"

2006 Feb 28
0
ActiveRecord: Legacy primary keys
Hi, I''m building a frontend for a legacy schema, with tables like this: CREATE TABLE `types` ( `a_type_cd` varchar(6) NOT NULL default '''', `a_type` varchar(30) NOT NULL default '''', PRIMARY KEY (`a_type_cd`) ); The primary key is specified by the user (not auto-generated), and needs to be updateable. I create the following a base class to
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)
2006 Mar 13
1
adding custom cache field
Hello, I needed to add custom cache field for one of my application. I thought I will share the code showing how to do this. This code below creates and maintain a custom cache field, for keeping track of totals. Say, you have accounts, and for each account there are transactions (either deposit/withdrawal), and one will like to keep track of the total balance for an account. So, let there be a
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
2005 Dec 22
0
Errors object missing when saving AR in Web Services method
Hello, I''m not able to get Errors object when saving some Model instance in ActionWebService::Base subclass. I want to create API method that will return ID of the object when saved successfully. When validation fails and the object is not saved I''d like the method to return ID, as well as the array of ValidationError custom struct. But I cannot fill in this because unsaved
2008 Sep 17
0
permalink_fu and classes with different primary_key than id?
Has anyone else had problems with this scenario? class Team < ActiveRecord::Base # Primary key self.primary_key = ''team_id'' has_many :players, :foreign_key => :team_id has_permalink :city, :param => true end I am getting all kinds of trouble - that goes away if I comment out the has_permalink declaration. With PermalinkFu: >> fs = Team.new =>
2012 Mar 02
0
ConnectionNotEstablished when using connection on AR::Base abstract subclass
I''m using AR outside of Rails and calling establish_connection on an ActiveRecord::Base abstract_class subclass (to protect my connection in case anyone else is using AR). It was working just fine with AR 3.0.9, but I recently attempted to upgrade to AR 3.2.2. Now, when I hit a "nested" query from a has_many, I get a ActiveRecord::ConnectionNotEstablished. If I call
2006 Mar 13
0
Getting AR to downcase table and column names
I''m looking for the cleanest way to force the Rails framework to use a lower-case version of the table and column names in a database when creating records. I need this for a Rails application that displays the status of an existing backup system. The backup system (Bacula; Nice backup system, BTW) can use either Postgres or Mysql as its database engine. Unfortunately, the table and
2010 Jun 16
2
class methods from module where active rec is involved
I have a module as shown below and when I extend an active record to use it, I can not access the primary_key method. In a simple test program using a similar approach where active record is not involved, access to the class methods seems to work ok. What can I do to make this work or so that I can access the class methods ? ################################## require
1995 Dec 28
0
No subject
>From owner-majordomo Thu Dec 28 05:29:23 1995 Received: from irz301.inf.tu-dresden.de (irz301.inf.tu-dresden.de [141.76.1.11]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id FAA04159 for <announce@freebsd.org>; Thu, 28 Dec 1995 05:29:12 -0800 (PST) Received: from sax.sax.de by irz301.inf.tu-dresden.de (8.6.12/8.6.12-s1) with ESMTP id OAA04823 for
2011 May 23
3
Passing a period as part of an id in show action
I am trying to do the following in a RESTful manner: I have a web service that accepts an id to deliver a particular record. Unfortunately, the id that the client will have is not the usual database sequence number. This mostly works, though, and the url looks something like: http://myservice.com/controller/the_id.xml That is handled by the "show" action. Unfortunately, some of
2006 Jul 06
0
Can''t generate AR from script (ActiveRecord::ConnectionNotEstablished)
Generating ActiveRecord instances from the console works fine. ./script/console Loading development environment. >> Pim.new() => #<Pim:0xb74427dc @attributes={"vpimitem"=>nil}, @new_record=true> >> But running this little script: #!/usr/bin/env ruby require File.dirname(__FILE__) + ''/../config/boot'' Pim.new() Will spit out
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
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
2012 Aug 21
0
CEBA-2012:1184 CentOS 5 perl-XML-SAX FASTTRACK Update
CentOS Errata and Bugfix Advisory 2012:1184 Upstream details at : http://rhn.redhat.com/errata/RHBA-2012-1184.html The following updated files have been uploaded and are currently syncing to the mirrors: ( sha256sum Filename ) i386: 85aed94f1ee9a2c4886d2bbca6ccd73b59d9e9e0903f866c84e12219703faeca perl-XML-SAX-0.14-13.el5.noarch.rpm x86_64:
2006 Jul 16
0
Why does belongs_to handle "conflicts" this way?
When you define belongs_to in a model, you can either access association or association_id. I was wondering how Rails would handle things if you set each one to be different. I made two simple models: class Foo < ActiveRecord::Base; end class Bar < ActiveRecord::Base belongs_to :foo end Now here''s a script/console session. >> f = Foo.create => #<Foo:0x270ec10
2006 Jul 12
7
Failure in comparisons
I''m basically a Ruby noobie. At the moment I''m having a fair bit of trouble trying to figure out what''s going wrong here (partial template): <%= @project = Project.find(@the_id) if current_user.userid == @project.client hidden_field ''messages'', ''recipient'', ''value'' => @project.project_manager
2006 Jan 06
0
bug rails activerecord association join
hi, I found a bug in ActiveRecord association SQL INNER JOIN codes. in has_many, has_one, habtm and belongs_to queries the foreign key is determined from the table name of reflection and self. but that''s worng because if you use a global prefix or suffix for your tables the foreign keys will be in format of PREFIX_CLASSNAME_SUFFIX_id which is wrong, because it breaks the advantage of
2011 Nov 14
0
CentOS-announce Digest, Vol 81, Issue 7
Send CentOS-announce mailing list submissions to centos-announce at centos.org To subscribe or unsubscribe via the World Wide Web, visit http://lists.centos.org/mailman/listinfo/centos-announce or, via email, send a message with subject or body 'help' to centos-announce-request at centos.org You can reach the person managing the list at centos-announce-owner at centos.org When
2007 Oct 22
1
self-referential habtm: why are my keys null?
I''m trying to set up a directional self-referential HABTM to represent an arbitrary semi-hierarchical structure; it works for any data prepopulated into the db, but when I try to create a new relationship, I just get NULLs in both key columns (or 0''s if I turn on the no-null constraint). Here are the migrations: class CreateNodes < ActiveRecord::Migration def self.up