Displaying 20 results from an estimated 60000 matches similar to: "WHERE NOT syntax with ActiveRecord"
2007 Jan 20
2
find_by_sql with named parameterized sql
I tried to use named parameters in my SQL query , using find_by_sql
Order.find_by_sql ([select * from orders where amount > ? and quantity >
?", [ @amount, @quantity ] works;..
but
Order.find_by_sql ([select * from orders where amount > :amount and
quantity > :quantity ", [ :amount => @amt, :quantity => @qty ] is not
working
a I wrong or should I use a plain select
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
2008 Sep 17
13
Capturing the sql from a statement without executing it?
Hi guys,
Is there an elegant way to capture the sql that would have been
executed by an ActiveRecord statement, without actually executing
it? :)
I''m imagining something like
sql = User.find(1).groups.to_sql
or perhaps
sql = ActiveRecord::Base.capture_sql { User.find(1).groups }
resulting in sql = ''SELECT * FROM groups INNER JOIN memberships....
WHERE users.id =
2006 Dec 14
3
Problem with ActiveRecord and Associations
Hi,
I''m having what I believe to be a typecast problem with ActiveRecord and
Associations. In the code below, I need to flag a contact record for
deletion if the contact doesn''t have any addresses or books records:
sql = "select id, delete_flag from contacts where id = #{params[:id]}"
contact = Contact.find_by_sql(sql)
if (contact[0].addresses.count +
2008 Sep 08
1
ActiveRecord::StatementInvalid Error
Hi There,
I''m gettings the following errors while accessing my application.
Can someone please tell what is the possible cause and can it
be resolved.
"
ActiveRecord::StatementInvalid in Site#showalladdress
Showing site/showalladdress.rhtml where line #3 raised:
Mysql::Error: #42000You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version
2007 Mar 25
5
Insert text into text area field with RJS
Hi,
I''d like to insert/append some default text into a text area after
clicking on an image button ''test.png'' in edit.rhtml:
<%= link_to image_tag("test.png"), url => { :action => :new_text } %>
Action:
# article_body is the textarea''s id.
def new_text
render :update do |page|
page.insert_html :bottom, :article_body,
2009 Mar 25
6
Hash with key and value from ActiveRecord?
Heya,
I think I have thinking barrier. I just want a simple hash out of an
ActiveRecord.
@attributes = Attribute.find_all_by_character_id(@character).hash {
|u| [u.name, u.value] }
and I would like to access it like
@attributes[:health]
but it doesn''t work. Anyone can help me out with that?
--
Posted via http://www.ruby-forum.com/.
2007 Mar 09
3
Unicode not working under Mongrel
hi!
I started my app in mongrel and everything works fine, except that it
doesn''t show the unicode chars right. it worked under WEBrick.. where
should I start tackling the problem?
thank you!
david
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on
2007 Nov 30
2
find_by_sql preformance problems when ordering data
Hi,
I am bumping into a small problem I was hoping someone could send me in
the right direction on.
I''m counting votes from a votes table to try to find the top ten videos.
The following works really well, until I try to order it. It would seem
that the order by is adding a 26 second delay, which surprised me since
it was all done in sql. I revised the process to sort and publish on
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>,
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
2008 Feb 25
4
Using group in with find in an ActiveRecord appropriately
I''m playing around with the Practical Rails Projects code, and was
attempting to make a change for graphing data differently using
groupings.
Basically the code went from:
total_weight = @exercise.activities.collect {|e| e.repetitions
* e.resistance}
workout_dates = @exercise.activities.collect {|e|
e.workout.date.to_s}
To:
total_weight =
2008 Nov 13
5
Touch an ActiveRecord - timestamps
When I update an ActiveRecord, i would like to "touch" one of the
related objects, that the updated record belongs_to, in order to update
the timestamps on the parent record, although i don''t want to change any
of the data in the parent. Whats the accepted way to do this?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You
2006 Jan 12
5
Question about using DISTINCT in ActiveRecord find method.
Hi,
Am relatively new to the RoR world. My question is quite simple.
I have a query like such:
shipmentNumbers = Order.find_by_sql(["select distinct s.id from orders
o, line_items li, shipment_lines sl, shipments s where o.number=? and
o.id = li.order_id and li.id = sl.line_item_id and sl.shipment_id =
s.id", number])
The above query works fine. I wanted to do the same query using
2007 Mar 24
6
Rails Development Log
Hi,
I am using Ruby+Rails with Mongrel.
Is there any way to disable logging so that everytime I start rails
(mongrel_rails start), it doesn''t automatically start logging info to
development.log
Thanks!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on
2007 Nov 02
3
Date Issues + Oracle + RoR
Hi Experts
I''ve a product like this
ID -> 1
Name -> Xyz
Price -> 30
Created_at -> 02-NOV-07
from_date = Date.new(2, 10, 07)
to_date = Date.new(2, 10, 07)
@product = Product.find_by_sql("select * from products where
created_at between from_date and to_date")
code works perfectly, buy my issue is i dont get any data. always says
no record found
but if i use
2007 Dec 07
7
activerecord 2.0.1 gem
I have tried to install activerecord 2.0.1 both through gem update and
by manually downloading it and doing gem install. They both fail with
MANUAL:
C:\DRC\ruby>gem install activerecord-2.0.1
ERROR: Error installing gem activerecord-2.0.1[.gem]: buffer error
REMOTE:
R:\workzone\dwell-aware\trunk>gem update --source
http://gems.rubyonrails.com
Updating installed gems...
Attempting remote
2008 Feb 01
5
ActiveRecord - find
Hi-
What I would like to do is select a single column out of my model, say
the column is called my_column, and store the result in an array,
which it should be, right?
For example, if I do:
@my_arr = Model.find(:all, :select => "my_column")
This should fill @my_arr with all the values from "my_column", right?
So then I can access the data by some_other_variable =
2011 Aug 25
3
ActiveRecord searching in batch (with find_by_sql)
I have an issue where I am getting a large number of records from the
database and I cant afford to keep it in the memory due to performance
issues.
Therefore using the following would be ideal,
User.find_each(:batch_size => 5000, :start => 2000) do |user|
NewsLetter.weekly_deliver(user)
end
however,
I would like to use find_by_sql since my query is user defined. Question
is, is it
2007 May 08
2
ActiveRecord::RecordNotFound error
I was having problems with ActiveRecord::RecordNotFound in my code, so
did a search on the forum here, and I got an application error.
search string:
ActiveRecord::RecordNotFound
I am just reporting this so somebody could fix the problem?
Andrew
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are