similar to: How do you execute arbitrary SQL with ActiveRecord?

Displaying 20 results from an estimated 60000 matches similar to: "How do you execute arbitrary SQL with ActiveRecord?"

2006 Jul 04
8
inherits_from: Multiple table inheritance
Hey guys, I just implemented very simple and primitive class table inheritance in ActiveRecord. The goal is for this to become mature enough to become a true feature in Rails. Check it out here: http://guest@blog.raylucke.com/svn/inherits_from Here?s how it looks in action: create_table "books", :force => true do |t| t.column "product_id", :integer t.column
2006 Aug 18
2
Including CSS from a stylesheet file in a an e-mail
How can I include the contents of the file /public/stylesheets/print.css in an RHTML page for ActionMailer? Because there is no controller or session, none of the usual tricks work. Do you have to use basic file IO or there some convenience method I haven''t seen? Thanks Ashley -- "If you do it the stupid way, you will have to do it again" - Gregory Chudnovsky
2006 Jul 27
3
Subversion library for RoR
Hi everybody, Is there a gem or something for working directly with Subversion from a RoR app? Thanks, Tiffani A.B. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060727/26846e72/attachment-0001.html
2006 May 25
3
Storing BigDecimal in the db
I need to do some precise math, going to 12-14 decimal places, so I''m using BigDecimal. How can I store this in a db? I''m using postgresql 8.1.0, if that matters at all. I found a plugin [1] but it gives me the error "You have a nil object when you didn''t expect it! The error occurred while evaluating nil.each_pair," with no line number. The plugin itself
2006 May 03
3
SQL book for Rails developers?
I can design basic Rails models without any trouble, and I feel pretty comfortable at the mysql command prompt. But some of these new database features in Rails 1.1 have me scratching my head: polymorphic associations, join models, etc. What is all that? I think I need a book that covers the advanced database topics one would need to know as a Rails developer -- not necessarily
2006 May 15
4
Other databases...
I''m a newbie to Ruby and I was wondering if Ruby on Rails will work with databases that has a ODBC/JDBC driver or does it ONLY work with the databases that it list in it''s documentation? Thanks -- Posted via http://www.ruby-forum.com/.
2006 Jun 20
3
Rails and decimal types mapped to float
Hi, I''m a brazilian developer, work in a hospital and we have a legacy database that we want to access via rails. Rails maps decimal types to float, and to circumvent this problem the suggestion one can find on the list is to represent decimal values as cents. That''s not applicable when you have to access a legacy database. I found two tickets 4274 and 4605 on rails trac,
2006 Apr 04
1
Parsing a SQL file directly into activerecord::execute method
Hello folks, I''m trying to do something like: 1. db = ActiveRecord::Base.establish_connection(:adapter => "mysql", :database => "app_development", :username => "root") 2. Cmd = File.read(''commands.sql'') <--- Command.sql contains multiple valid SQL statement. I''ve tested this directly by piping it into MySQL from the
2006 Apr 28
5
Migrations - use them or not?
Hello, As a rails newbie, i have stumbled upon some tutorials promoting migratons. I have thought, wow, cool and started using them right away. However, now that i am reading the RoR list on a daily basis, i have seen also mails ranging from ''migrations are not always the best'' to ''migrations are evil'' and even ''i would not use migrations even
2006 Jul 02
7
Generic SingleTable inheritance
Hi all, I would like to discuss a design idea I have in mind with you, in order to get critical feedback. ActiveRecord supports single table inheritance(STI) "per se", BUT you must add all possible instance variables(properties) of all subclasses to the "base table"(as columns). I would like to circumvent this restriction. Say we have a class AbstractGenericThing <
2005 Dec 12
2
How to use arbitrary relationships in Activerecord
How can I ask ActiveRecord to make it''s "has_many" code to work on some arbitrary relationship between two tables? ie neither field is a primary key The situation is that I am writing a Postfix management application and one of the tables to manage is the "alias" table. My primary key in the "mailbox" table is "id", but the alias table is just
2006 Aug 13
2
Arbitrary "Columns" for ActiveRecord
I''m having a bit of a tough time coming up with a good solution for what I''m trying to do. I''ve come up with a couple of solutions that work pretty well but many use way too many queries or are just not very good. Basically I want to store something of a property list for a model. class Model < AR has_many :properties, :dependent => :delete end class
2006 Aug 01
5
how do set default value for ActiveRecord fields?
Everytime a new record object is created i.e. Record.new, i want certain fields to be the same. Any idea how to do this? Thanks Chris -- Posted via http://www.ruby-forum.com/.
2006 Apr 20
5
How to find the last SQL statement executed in ActiveRecord
Is there a method for retrieving the last SQL statement executed by ActiveRecord? I realize I can open the log file, but I''m looking for a programmatic way. -- Posted via http://www.ruby-forum.com/.
2006 Aug 12
7
Override method in ActiveRecord
Hello, there is a method ActiveRecord::Base#exists? . I would like to override this method in a class ActiveRecord. Could anyone tell me how to do it? TIA -- Posted via http://www.ruby-forum.com/.
2006 Sep 25
1
ActiveRecord instead of direct sql execution
Hi all, I have 2 tables and a standard one-to-many association. How do I substitute the following sql with ActiveRecord calls so that it uses just one sql statement: update geo_entities set terminal_id = 3 where id = 10 or id = 23 or id = 87; Thank you! Regards, Yuri Leikind --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to
2007 Feb 28
12
Specifying that code is called in a block
Not sure if this is possible currently. I have a section of code like this: ActiveRecord::Base.transaction do cow.save! duck.save! dog.save! end (Names changed to protect the innocent.) I''d like to specify that the saves run in a transaction. I can do ActiveRecord::Base.should_receive(:transaction).and_yield But is there any way to specify that the code is
2006 Mar 29
3
Loading records during class definition
I''ve created a look-up table in my database that currently has 4 rows. I want to access these as constants in the application because that''s effectively what they are. I tried this... class StockRuleLevel < ActiveRecord::Base has_many :stock_rules SITE = find(:first, :conditions => "type_code = ''site''").id MAKE
2006 May 04
7
ActiveRecord and SQL Server
Hi all, I am exploring using RoR for a new project but have run into a problem with ActiveRecord and SQL Server''s timestamp datatype. We have a NOT NULL timestamp column in a table and ActiveRecord keeps trying to update it, which promptly causes it to blow up. I have tried making the value NULL for insert and update in the model, but SQL Server doesn''t like that
2007 Feb 12
6
Specs for Ajax partials with unicode characters
Hi Not sure if this is more Rails or RSpec related... I''ve got an app with an RJS view that updates a div in a page with the contents of a partial. The partial contains a non-ascii character namely a pound sign. I set up a simple test app with this RJS view: page.replace_html("test_div", :partial => "test_action") and this _test_action.rhtml: