search for: table_name

Displaying 20 results from an estimated 287 matches for "table_name".

2006 Feb 07
5
OCI adapter slowdown on dictionary access
Hi, after some experience with Rails on MySQL databases I gave it a try on one of our larger Oracle database. I was facing a problem when Rails tried to detect the columns for a model/table. The appropriate statement ran about 1 min which led to a timeout. Our Oracle guru told me to analyze the SYSTEM schema. After that hadn''t helped, he said the only remaining chance is to use a
2006 Jan 11
8
Oracle and Rails seems really slow.... In development
...e, data_default, nullable, decode(data_type, ''NUMBER'', data_precision, ''VARCHAR2'', data_length, null) as length, decode(data_type, ''NUMBER'', data_scale, null) as scale from user_catalog cat, user_synonyms syn, all_tab_columns col where cat.table_name = ''USERS'' and syn.synonym_name (+)= cat.table_name and col.table_name = nvl(syn.table_name, cat.table_name) and col.owner = nvl(syn.table_owner, user) I am assuming that this is because development mode can''t cache the models... in production mode it seems to take abo...
2006 May 15
8
set_table_name and self.table_name
I have some legacy tables that I used set_table_name on, I''m attempting to write a method that will get key value from a sequence table and then update it and return a value. I''m hoping to put this in the base ActiveRecord method so I would like to reference the table name with self.table_name or something... class Contacts &l...
2007 Oct 31
1
how does table_name static method work ?
There has to be a simple explanation for this. I can do this to get the table name behind a model >> User.table_name => "users" Great. But looking at the table_name code in active_record/base.rb, the table_name method is not static (no self.)! def table_name reset_table_name end So why can I call table_name as a static method ??? --~--~---------~--~----~------------~-------~...
2010 Mar 30
2
remove_index missed quote_table_name
in lib/active_record/connection_adapters/abstract/schema_statements.rb there is a missing quote_table_name in line 286 (def remove_index): execute "DROP INDEX #{quote_column_name(index_name(table_name, options))} ON #{table_name}" so my "keys" table can get an index with "add_index" but can''t remove it (without tweaking) replacing it to execute "DROP INDE...
2005 Apr 23
2
[Tip] Introspection to determine if a column may be null
...er adaptors. # From my own lib/rails_extensions.rb file, included in config/environment.rb class ActiveRecord::ConnectionAdapters::Column def required? @required end end class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter alias_method :_real_columns, :columns def columns( table_name, name=nil ) cols = _real_columns( table_name, name ) cols.each{ |col| sql = "select is_nullable from information_schema.columns where table_name=''#{table_name}'' and column_name=''#{col.name}''" col_is_required = nil log(sql...
2006 Jul 28
0
reserved words
...ldap server you are working with and a management area that lists what changes are to be done (with ability to cancel, etc..). So, there are no model files for the entries. They are created dynamically with the following lib: module Stone module Dynamic class << self def klass(table_name) tname = class_name_from_table(table_name) const_missing(tname) rescue NameError define_klass(table_name) end def objeck(table_name) klass(table_name).new end private def class_name_from_table(table_name) Inflector.ca...
2006 Jan 06
0
bug rails activerecord association join
...vantage of changing the prefix and giving it a go without chanigng any field names.. on the other hand the associations lik @blog.comments work just normal (using CLASSNAME_id). I fixed the problem by changing the determination of foreign key from table name to class name as following. I removed table_name references and replaced them with to_s''s to get class names.. I thought of using class_name method but it gives the parent class''s name in STI (I dont know if its the desired behaviour or is it also a bug) Is there a better way of doing this? I wanna submit a patch but couldnt be...
2005 Mar 08
4
change the model''s table name
I need to change the name of the table a model is connected to... like the example in the API... the table is called mice and I want a class called Mouse. class Mouse < ActiveRecord::Base table_name "mice" end I''m doing this cause I want tables in my language (italian) and avoid the nameS thing. just adding it in that way doesn''t work ArgumentError in Tipo_trasporti#index wrong number of arguments (1 for 0) /app/models/tipo_trasporti.rb:2:in `table_name'&...
2010 Aug 04
1
Question regarding S4 objects and reading in excel data with RODBC
...R' book written by Phil Spector. It seems very straightforward, yet I get the same error everytime I try it, with different excel sheets and trying to tweek the code a bit. This is what I do: library(RODBC) sheet='X:\\example.xls' con=odbcConnectExcel(sheet) tbls=sqlTables(con) tbls$TABLE_NAME qry=paste("SELECT * FROM '",tbls at TABLE_NAME[1],"'", sep=" ") The error I get is: Error in paste("SELECT * FROM '", tbls at TABLE_NAME[1], "'", sep = " ") : trying to get slot "TABLE_NAME" from an object (c...
2013 Feb 18
6
How to clear ActiveRecord query cache on associations with dynamic table
...;m aware of the single thread conditions. I''ve tackled some caveats yet - will post a blog about it soon - but there''s one I need help with. Consider 2 models that are associated: Order and OrderLine where Order has many order_lines. Now we set the table names for them: Order.table_name=''v1_orders'' OrderLine.table_name=''v1_order_lines'' Query: OrderLine.joins(:order).where(Order.table_name=>{:customer_id=>1}).all Result: Select v1_order_lines.* FROM v1_order_lines INNER JOIN v1_orders ON v1_orders.id=v1_order_lines.order_id WHERE v1_orde...
2009 Sep 22
6
Import excel / csv files
Hey, What way is the best to do imports of CSV files?
2005 Aug 16
1
Defining model classes for enumerations
...enums.each do |spec| if spec.kind_of?(Hash) class_name = spec[:class_name].to_s raise ArgumentError, ''An enum specification must contain a :class_name'' if class_name.empty? order = spec[:order] || ''position'' table_name = spec[:table_name] || class_name else class_name = spec end module_eval("class #{class_name} < BoilerPlate::EnumRecord; end") enum_class = const_get(class_name) enum_class.table_name = table_name enum_class.preload(:order =&gt...
2013 Mar 07
0
custom table_name for table users with devise
Hi for my app, I have several tables for users (franceusers, belgiumusers, ...) and I would like to use one or another depending on domain I tried with table_name_prefix and table_name but it seems to not work class User < ActiveRecord::Base rolify # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, #:confirm...
2007 Sep 13
7
Namespacing Models
Hello everyone, Do you feel it? The little shiver down your spine when you think of "namespacing" in rails? To some thats a common feeling, to people like myself who enforce absolute organization have already thought about the need for namespaces in rails. Now I do understand this is an ongoing effort... to some degree. Controllers and routes, from my experiences work well, that being,
2005 Nov 18
6
wrong number of arguments (2 for 1) error message help
....id}") @itemdesigns = ItemDesign.find_all_elements(itemtablename) render :action => ''page2'' end Now the ItemDesign is a model class that i created myself right now it looks like this in its entirety: class ItemDesign < ActiveRecord::Base attr_accessor :table_name def self.find_all_elements(table_name) @table_name = table_name find_by_sql("select * from ?", @table_name) end end The problem is that I am getting the wrong number of arguments (2 for 1) error that is in the subject. I have tried an initialize definition in the model cl...
2006 Apr 04
5
How to implement tag clouds using plugin?
...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) o, t, o_pk, o_fk, t_pk, t_fk = table_name, tag_model.table_name, primary_key, taggable_foreign_key, tag_model.primary_key, tag_foreign_key jt = tags_join_model ? tags_join_model.table_name : tags_join_table sql = "SELECT #{t}.#{t_pk} AS id, #{t}.name AS name, COUNT(*) AS count FROM #{jt}, #{o}, #{t} WHERE #{jt...
2006 Mar 23
11
ActiveRecord: Oracle metadata loading slow on large database
All, While attempting to use ActiveRecord against a large database, approx. 1700 tables and 4 million rows, I discovered an inefficiency in oci_adapter.rb. The problem seems to be the SQL being generated to lazy-load the columns metadata. "def columns(table_name, name = nil)" method generates the following SQL: select column_name, data_type, data_default, nullable, decode(data_type, ''NUMBER'', data_precision, ''VARCHAR2'', data_length, null) as length, decode(data_type, ''NUMBER'', data_scale, nu...
2006 Feb 16
1
[PATCH] acts_as_taggable plugin
...le.rb =================================================================== --- lib/acts_as_taggable.rb (revision 3214) +++ lib/acts_as_taggable.rb (working copy) @@ -25,12 +25,23 @@ module SingletonMethods def find_tagged_with(list) find_by_sql( - "SELECT #{table_name}.* FROM #{table_name}, tags, taggings " + + "SELECT DISTINCT #{table_name}.* FROM #{table_name}, tags, taggings " + "WHERE #{table_name}.#{primary_key} = taggings.taggable_id " + "AND taggings.taggable_type = ''#{acts_as_tag...
2006 Jan 19
3
problems with migrations in sql server
...LUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType, COL_LENGTH(''schema_info'', COLUMN_NAME) as Length, COLUMNPROPERTY(OBJECT_ID(''schema_info''), COLUMN_NAME, ''IsIdentity'') as IsIdentity, NUMERIC_SCALE as Scale FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ''schema_info'' 54 SQL:BatchCompleted SELECT TOP 1 version FROM schema_info 54 SQL:BatchCompleted SELECT TOP 1 version FROM schema_info 54 SQL:BatchCompleted CREATE TABLE Foo ([id] int NOT NULL IDENTITY(1, 1) PRIMARY KEY, [Name] varchar(50)) 54 SQL:BatchCompl...