Displaying 20 results from an estimated 2000 matches similar to: "find_by_sql without a model? how to do this?"
2008 Jun 17
6
Book released "Aptana RadRails: An IDE for Rails Development"
Hi,
Some months ago, a person from Packt Publishing posted a message in this
list looking for potential Authors/Reviewers for new Ruby on Rails
books. Now I''m proud to announce my book [1] "Aptana RadRails: An IDE
for Rails Development".
If you are using [2] Aptana RadRails, or if you are looking for an IDE
and you still haven''t decided which one to use, you might
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:
2008 Feb 05
5
how can my model reference a helper?
I know, I know, they''re not allowed to. But here''s my problem. I''ve got
a really simple model with two fields, name and price, which I want to
show in a form select drop-down. "collection_select" takes a
''text_method'' parameter, which is the method in the model that gets its
value placed in the <option> tag.
Because I want to show both
2006 May 23
8
ad-hoc query
How do you run an ad-hoc query that does not belong in any model? I
thought it was something like ActiveRecord::connection.find("my
query..."), but I can''t seem to find the documentation on it. I know
I''ve seen it somewhere before, though.
thanks,
Jeff
--
Posted via http://www.ruby-forum.com/.
2007 Aug 14
1
find_by_sql vs connection.select_all
I was trying to do SUM based mySQL query simliar to the following:
SELECT SUM(updated_on - created_on) AS total from signups
If I were to run this command in the mySQL console I would get a
result. However, if I were to run it using the following command in
Rails:
Signup.find_by_sql("SELECT SUM(updated_on - created_on) AS total from
signups")
The query that is written to the log is:
2006 Apr 21
5
Simple Question: How to merge SQL results?
Hopefully an easy one, how do I merge two or more SQL query results?
Example:
result1 = find_by_sql(x)
result2 = find_by_sql(y)
What is the best way to merge result1 and result2? I want to be able
to reference the objects as if they were obtained via one query.
Cheers,
Dan
2009 Apr 11
6
Inserting data from 1 table to another by using find_by_sql
Hi All,
I am inserting data from one table to another by using following method
@data=RoyaltyReportFiles.find_by_sql("insert into royalty_reports
(artist_name, album_name) select artist_name, album_name from
temp_royalty_reports where id=328417")
it saves the data into royalty_reports table but it gives following
error and application crashes. i am using rails 1.2.5
You have a nil
2006 Nov 12
2
Model-less SQL results
I''m trying to get some stats from my database about my model, and I''m
not sure how to go about it.
If I have a model ''foo'' that has an attribute ''color'' and I want to
get some counts on this I could use the sql:
SELECT color, COUNT(*) AS count
FROM items
GROUP BY status
which would return something like:
+--------+-------+
| color |
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.
2008 Mar 07
3
Boolean circles..
Hi,
This is just kindof a RoR question, but since you all potentially do
the same things as I do, I thought I''ll ask here..
Im trying to use the boolean type in the database. Migrations is no
problem, it even converts the 0/1 values from my import CSV to false
and true.
However, I cannot make the :conditions part of a find work:
Loading development environment (Rails 2.0.2)
>> c
2007 Nov 15
4
Using .find_by_sql for database/admin queries
I want to create an internal admin view to display the output of "show
variables" from mysql. What''s the best approach do this?
For example, I''m doing something like this:
@variables = ActiveRecord::Base.find_by_sql "show variables;"
Then, I get stuff like this back (227 elements in @variables) in
script/console:
>> @variables[0]
=>
2006 Jun 23
1
''Series'' Pluralization
Howdy,
I have a model I called ''content_series''. I created it and noticed that
Rails called it ''Sery'', so I added ''series'' to the uncountable thing in
the config, like this:
Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, ''\1en''
# inflect.singular /^(ox)en/i, ''\1''
#
2007 Jan 25
3
Sum multiple columns individually
Can you sum a few columns at a time?
I tried
x =Calc.find(:all, :select => "sum(amt1) amt1, sum(amt2) amt2"
:conditions => ["where date > ?", date] )
The sql seems to function properly, but I wasn''t able to grab the
values. These just failed
x.amt1
x.send("amt1")
I tried changing up the query to use
sum(amt1) as amt1
sum(amt1)
2011 Sep 18
9
Rails 3 and postgresql
I have a simple project created around a very, very simple database: one
main table packs with just three rows
Column | Type |
Modifiers
--------+-----------------------------+----------------------------------------------------
id | integer | not null default
nextval(''packs_id_seq''::regclass)
nombre | character
2007 Jul 14
1
performance bottleneck
I have got my database in Mysql. I used ferret to index a table with 10
million rows. On limiting the selection of data to 1000 initial retrieval,
it takes 200 seconds but for the whole table it took more than four hours
and after which i had to close my indexing application. I used the
StandardAnalyser for it. There is no problem from the database side as
retrieval of all the data in the table
2005 Oct 17
8
Using active record for SELECT MAX(column) FROM ...
Hi,
Is there an easy way of querying an active record for a maximum column
value? I need to do queries like:
SELECT MAX(salary) FROM employees
TIA,
Jeroen
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)
2007 Jan 16
3
odd error with sqlite3 adaptor
Any idea what would cause this?
>> icps = Icp.find(:all)
ActiveRecord::StatementInvalid: SQLite3::SQLException: unsupported file
format:
SELECT * FROM icps
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_recor
d/connection_adapters/abstract_adapter.rb:120:in `log''
from
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_recor
2011 Jan 06
4
Not able to insert value in rails console
I am using authlogic for authentication in rails 3.0.3 with ruby 1.9.2
Using activerecord-sqlserver-adapter (3.0.5)
windows with sqlserver database
when i create user details in rails console, i am getting below error,
>User.create(:login=>''test'',:password=>''test123'',:password_confirmation=>''test123'')
2008 Jun 19
6
How to use SQL without a model?
I want to do a SQL query, but I haven''t created a model. For example,
instead of Car.find(:all) I want to be able to use SELECT * from cars. I
don''t have a Car model because this DB was not created with Rails (it''s
from a PHP project).
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you