similar to: How to execute an SQL statement in rails?

Displaying 20 results from an estimated 1000 matches similar to: "How to execute an SQL statement in rails?"

2006 Jul 05
10
Scalable alternative to #find_all
Is there any scalable alternative to iterating all the records of a certain model? #find_all seems to load everything into memory. With 500.000 records it will be a swap storm. Pedro.
2007 Jan 18
4
Defining the expected behavior of DatabaseStatements.execute()
It would be very helpful if the core team could define and document the expected behavior of DatabaseStatements.execute(). The implementations appear to vary. Most adapters will return some sort of native result set, SQL Server returns nil and expects a block, DB2 and Sybase return the affected row count. So please, will someone in core explain the expected behavior and can the execute()
2008 May 30
9
find_by_sql without a model? how to do this?
Hi, I''d like to do a "find_by_sql" without a model (e.g. <model name>.find_by_sql("...")) as the results I get back are a once off special, and I''m happy to handle them as an array. How do I do this? "ActiveRecord::Base.find_by_sql(...)" does not seem to work? Background - At the moment I''m doing within a model <model_name>,
2005 Jan 28
16
primary_key_prefix_type, support for non-integer primary keys
Hello! I''m just starting out with Rails--and Ruby itself for that matter--and have a couple of questions regarding primary_key_prefix_type and non-integer primary keys. I see in the ActiveRecord documentation [1] that by default the primary key of a table "foo" is expected to be "id", though primary_key_prefix_type this can be changed to :table_name or
2006 Jan 09
3
rails ignoring the migration file
I have a mysql database that I am trying to use migrations on. The problem that I am having is that when I create a blob field in my migration file like so: t.column "data", :binary, :limit => 15.megabytes, :null => false rails changes it to this in the schema: t.column "data", :binary, :default => "", :null => false not only is this not what I wanted
2006 Jun 15
4
testing with transactions
Hello! I experienced problems with testing transactions which are supposed to be rolled back, but are not, because of transactional fixtures eliminating the inner transaction. Can this be worked around somehow without turning off transactional fixtures? Maybe savepoints can help this? Does anyone have any experience with savepoints to achieve nested transaction functionality? Both Postgres
2005 Nov 03
9
[Idea] session-wide persistent variables
I was thinking about having instance variable stored and fetched from session container automatically before calling an action and after the action is finished. Using methodology of accessors it would look like: class MyController < ActionController::Base persistent_attr :person def alfa person = ''John Smith'' # render as usual view alfa.rhtml with anchor
2006 Mar 02
2
custom sql queries beyond CRUD
Hi, I am just starting of in rails. I am trying to understand the features of rails and I have this burning question. (and search is not available now): Apart from relying on the automatic CRUD sql script produced, is there a way I can create my own sql script ex: with many joins between exixting tables (for reporting ). All I need is to declare the custom query and place the result in a
2009 Aug 19
2
Create! Syntax
Hey All, Two questions. Firstly, what is the difference between create and create! I see that create is document in the api http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002269 What is the difference between the two of these functions and where is the create! function defined. Also, What are the differences between these two calls? a) SomeModel.create!{ :property_a =>
2005 Mar 03
19
Better tools for authoring the view
I''m hand editing my .css and .rhtml files using SciTE and hitting refresh in my browser to see the results - its slow going. What tools are people using to author their .css and .rhtml files? Thanks, Neville _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
2008 Mar 03
1
Rspec and plugins
I have a question regarding best practices around module and plugin testing for rails applications. In our application we have created several plugins that extend ActiveRecord::Base with class methods, that when invoked in a model add behavior to that model. For example ... class SomeModel < ActiveRecord::Base adds_some_cool_behavior adds_another_wicked_sweet_behavior end My
2006 Jan 11
8
Oracle and Rails seems really slow.... In development
I''m just looking into how to connect to Oracle using Rails. I''ve got everything connecting and working as it should. I have a Users table in Oracle: create_table "users", :force => true do |t| t.column "username", :string t.column "created_on", :datetime t.column "email", :string t.column "note", :text
2006 Apr 03
4
How to fake composite primary keys?
I know ActiveRecord doesn''t support composite primary keys, but I need to use one, and I need it ASAP. I don''t need any composite foreign keys, luckily; what I have is a table that stores old versions of rows in another table, so the composite key is an id + date stamp. Would someone tell me a hack I can use to support this? -- View this message in context:
2006 Feb 07
4
Ruby, Rails & Inheritance
Hi! I am looking for a solution for the following problem: Some of my models share some attributes and also was in need for some extra features, so I created a class "RecordWithFeatures": ----------------------------------------------------------------- class RecordWithFeatures < ActiveRecord::Base # @Override def self.descends_from_active_record? superclass ==
2006 Jan 19
3
-517611318:Fixnum ... WTF?
I''m getting occasional errors that look like: Some method called for -517611318:Fixnum The method is constantly changing, and this error happens on ~5% of the page loads on my Mac Tiger development box. It''s happening on Ruby 1.8.2, and 1.8.4 compiled from source. I haven''t seen it on my Linux production boxes. I was wondering if anyone had seen this before? --
2006 Jan 11
2
NOOB: I need some Ruby/Rails Advice...
I''ve been doing lots of research about different languages and frameworks for a project I''m planning. Your help in deciding what to do would be of great assistance. I used to program in highschool for a couple years. I haven''t done much since then and I know i''m pretty useless as a programmer. I know that if i put my head to it, I could muddle my way
2006 Jun 15
3
Can I call MySql statements directly??
Hi All. I have a mysql statement that I would really really like to call from my Ruby program which goes like this: SELECT a, b, DAYOFWEEK(date_time) as DOW, HOUR(date_time) at hr, AVG(x/y) FROM records; This is possible by creating a 3-dimentional array of a, b, date_time containing x/y, and then finding averages and putting it into a 4-dimensional array of a, b, dow,
2006 Jul 12
1
When to use Mutex::synchronize?
I have a simple question when to the synchronize method in the Mutex class. Now that backgroundrb has allow_concurrency = true there is no need to synchronize database calls in threads. The question I have is lets say I have a simple method in my worker as follows: def some_method SomeModel.find_all each do |obj| obj.some_count += 1 obj.save! end end It accesses the database, but
2005 Apr 27
4
has_many syntax
Hi all, I have the following inside of an AR class definition: relationships=ActiveRecord::Base.connection.select_all(my_relationships_sql) relationships.each do |relationship| has_many RelatedItems, :class_name => relationship[''RelatedClass''], :foreign_key => relationship[''ForeignKey''] end This kind of works, but how can I assign the name of the
2011 May 11
2
Issue with Arel::SelectManager and insert Method
Hello, Arel::SelectManager (arel 2.0.9) uses following statement to insert a new record: @engine.connection.insert im.to_sql, ''AREL'', primary_key_name, primary_key_value But in DatabaseStatements insert ist defined as: insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) Actually, Arel::SelectManager does not use the sequence name. This leads to issues