SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: Execute direct SQL in rails
Hybrid View
-
Nov 23, 2005, 11:00 #1
- Join Date
- Jun 2004
- Location
- California
- Posts
- 440
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Execute direct SQL in rails
Hello,
How may I execute direct SQL in code?
Thanks
-
Nov 23, 2005, 11:36 #2
You need to use find_by_sql
Code:def self.find_by_url (url_title_variable = "index") find_by_sql ["select * from pages where url_title = ?", url_title_variable] end
-
Nov 23, 2005, 21:49 #3
- Join Date
- Nov 2001
- Location
- Atlanta, GA, USA
- Posts
- 5,011
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
There is also MyModel.connection.select("Whatever SQL query you want right here")
as shown to me here: http://www.sitepoint.com/forums/show...06#post2232921Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?
-
Nov 23, 2005, 21:49 #4
- Join Date
- Jun 2004
- Location
- California
- Posts
- 440
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks sam and vinnie. Both helped
Bookmarks