Displaying 20 results from an estimated 2000 matches similar to: "Getting AR to downcase table and column names"
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
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
2006 Mar 04
0
case-blinding db 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
2006 Apr 04
5
How to implement tag clouds using plugin?
The code on
http://blog.craz8.com/articles/2005/10/28/acts_as_taggable-is-a-cool-piece-of-code
is based on the acts_as_taggable gem,anybody has done that using the
acts_as_taggable plugin?thanks!
btw:the code above uses the tag_count method,which is defined in the
gem:
def tags_count(options = {})
options = {:order => ''count DESC''}.merge(options)
2006 Feb 16
1
[PATCH] acts_as_taggable plugin
hi,
I started today to use the acts as taggable plugin and it''s working as
expected.
I added a method find_tagged_with_all since I needed to find the
elements tagged with all the items in a list while find_tagged_with
finds all the elements tagged with any of the list terms.
Attached to this mail there''s a patch which adds the
find_tagged_with_all method and which solves a
2006 Jun 30
0
find_by_sql not quoting properly (in acts_as_taggable plugin)
I have run into a very strange problem discovered through the use of
the acts_as_taggable plugin, but related to quoting/sanitizing the
interpolated list in a find_by_sql. Apologies for the length, but I
wanted to be complete. ;-)
The method from acts_as_taggable.rb is:
def find_tagged_with(list)
find_by_sql(["SELECT #{table_name}.* FROM #{table_name},
tags,
2006 Dec 01
1
cannot use acts_as_ferret on legacy tables or tables with a
when i used "find_by_contents" on a legacy table with a different
primary_key than "id" i always got results=nil even when total_hits was
> 0
as a quick fix i changed line 261 in "class_methods.rb"
from:
conditions = [ "#{self.table_name}.id in (?)", id_array ]
to:
conditions = [ "#{self.table_name}.#{self.primary_key} in (?)",
id_array ]
2009 Aug 28
0
string downcase or how to use downcase an hostname in puppet?
Hi there.
I am trying to fix hostnames in our Redhat distributions.
Some of our server has some hostname un uppercase, and I need to change them
into lowercase because people that use the server rather like lowercase
hostnames...
I did some basic work :
Template :
$ cat /var/puppet/templates/rh-network.erb
# WARNING this file is autogenered by puppet. Any change there will
# be
2007 Jan 15
3
Wrong total_hits when using conditions in find_by_contents
I don''t know if this is a bug, or wanted behavior, but for me it was a
pain in... So here''s the problem + a bugfix.
Lets say you have a model "Article" with the following fields: title,
visible - and these records
[code]title, visible
ferret talk, 1
ruby talk, 0
ruby on rails, 1
lets talk about ruby, 1[/code]
If I let Article act as a ferret, and do:
result =
2006 May 06
3
Extending Rails plugins?
Gents,
I''m using the acts_as_taggable rails plugin (not gem), and would like to
add some additional methods to it. For example, the find_tagged_with
methods essentially does a find tag in a list (effectively an OR), while
I''d like to implement a find_tagged_with_all method that would implement
an AND (so if I specified 4 tags, it would only return items that were
2007 Jun 08
0
problem with rake db:sessions:clear and session_table_name
The comments in:
actionpack/lib/action_controller/session/activerecord_store.rb
document this method for changing the session table_name:
# You may configure the table name, primary key, and data column.
# For example, at the end of config/environment.rb:
# CGI::Session::ActiveRecordStore::Session.table_name =
''legacy_session_table''
#
2005 Apr 23
2
[Tip] Introspection to determine if a column may be null
I still want to get this into Rails for all connection adaptors, but
for now I''ve hacked my own addition on for just PostgreSQL.
The following code extends every Column object returned by
MyModel.columns to support a new #required? method, which indicates if
the column may or may not be null.
The following is a huge hack - suggestions on a cleaner way to add this
functionality
2006 Nov 11
0
acts_as_taggable plugin - paging through tagged model
Hi,
I''m using the acts_as_taggable plugin & wanted to page through all a
model''s records taggged with a particular tags.
i.e. page through all Model records that have been tagged with "artist"
I could not work out how to do this with the plugin, so I made the
changes outlined below.
Did I need to do this..? & does anyone else find this useful?
2006 Apr 07
2
Case Sensitivity and ID Field Naming
Hi,
I am working with an existing database that has table and field names
such as ''TblUsers'' and ''txtEmailAddress''. Is rails sensitive to the case
of the letters here? or can I simply refer to these tables and fields as
''tblusers'' and ''txtemailaddress'' in my controllers ad rhtml files?
Also, the database has id fields
2006 Jan 04
3
Legacy Table works-except edit?
Greetings,
I''m trying to put a Rails face on a Legacy Oracle 10 table. I am
currently setting the table_name and primary_key, and I get the list
and show to work fine.
However, when I hit edit I just get the Editing <table name>, Edit
button, Show, and Back. None of the fields are rendered.
Why would I be able to show these fields in the show and list, but not
edit them in the
2006 Aug 12
0
BUG in actionpack , error evaluating nil.downcase ?
hi all,
I try to deploy on my host (site5) on I have this error with
dispatch.fcgi start !
( RAILS_GEM_VERSION = ''1.1.6'' )
You have a nil object when you didn''t expect it!
The error occured while evaluating nil.downcase
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/request.rb:18:in
`method''
any idea ?
arnaud
2005 Aug 23
0
Fixtures: pluraly bitten
With my functional tests (on PgSQL) I get strange errors like this
1) Error:
test_create(AufgabeControllerTest):
ActiveRecord::StatementInvalid: ERROR: duplicate key violates unique
constraint "aufgaben_pkey"
Tracking this down, I found that sequences are only reset for some of
the tables I''m using. The reason? Inconsistent singularization.
I won''t go so far as
2004 Nov 22
0
Can''t set then read id on AR class in 0.8.5
I''m learning rails and have a test application which parses parts an
XML file to create AR objects and puts them in a database. The IDs in
the database are taken from the XML, i.e. I explicitly set them using
#id. The XML structure is mapped to AR relationships using has_many,
belongs_to etc. I''m using a SAX parser, creating objects when the
element start tag occurs and saving
2005 Dec 21
0
Overriding inheritance_column
I''m putting together a Rails application that will display information
from an existing database. The database has a "job" table that
contains a "type" column. I''ve successfully overridden the names of
the table and the name of the inheritance column by adding
def self.table_name()
''job''
end
Job.inheritance_column
2007 Apr 26
1
mapping column names in legacy schemata
I have a legacy MySQL database with a weird naming convention - all
table and column
names have a prefix ''_'' , which is annoying, and some of the column
names are misnomers.
I would like to apply a pre-defined mapping between MySQL column names
and method
names to be used in the Ruby class, without having the original column
names being visible anymore.
how can I pre-define a