similar to: Testing find_by_sql

Displaying 20 results from an estimated 50000 matches similar to: "Testing find_by_sql"

2007 Oct 15
3
NoMethodError
Hi to all!! I am new to ruby. I am trying to write a program to fetch the data from Database and written the data using pagination. I could get the data from DB. but pagination is not working. When i see the log file it is showing the following error. NoMethodError: undefined method ''paginatior'' #<Hash...> my pginate.rb and pagination.rb files are not in the same folder
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
2006 Sep 01
3
find_by_sql with :include?
When you use find, you can include related objects with include so that both objects get instantiated in the results, e.g. Foo.find(:all, :include => :bar). But when you use find_by_sql, is there a way to do this? You could definitely write the find_by_sql SQL to join Foo and Bar tables: Foo.find_by_sql("SELECT foo.*, bar.* from foo, bar where foo.bar_id = bar.id") But is there a
2006 Oct 02
2
when to use find_by_sql
I have a bunch of queries to compute some counters, like find_by_sql(<<-SQL SELECT p.*, c.nfavourites FROM people p, ( SELECT fp.person_id, COUNT(fp.user_id) as nfavourites FROM favourite_people fp, users u WHERE fp.user_id = u.id AND u.cluster = ''#{in_cluster_of_user.cluster}'' GROUP BY fp.person_id ) as c WHERE
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>,
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:
2008 Jun 23
1
Find_by_sql Doesn't Return Attributes?
My find_by_sql is not returning attributes of the calling model class. Thermo.find_by_sql("SELECT COUNT(*) FROM thermo WHERE thermo_loc = ''back'' GROUP BY DAYOFWEEK(time_on) ASC") # ==> [#<Thermo >, #<Thermo >, #<Thermo >, #<Thermo >, #<Thermo >, #<Thermo >, #<Thermo >] The sql is fine and when I checked it in a mysql
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 23
3
Finding distinct months using find_by_sql
Hello, I''m wondering if someone might be able to offer me a solution to the following problem that has so far stumped me. I''m trying to get the distinct months (and years) from a date field to display as a list in a view. For example, there might be a number of records stored with dates in the table ''headlines'': name date record1 21-09-2008 record2
2008 Jun 26
9
find_by_sql + Join + Rails 2
Hello I have write a code to select data from two tables (T1,T2) but the problem is @tables= T1.find_by_sql("select T1.*,T2.* from T1inner join T2on T1.followup_id = T2.id where followups.userid = ''41'' ") THe problem all values that is returned from running only T1 variables,why? Where are T2 variables?? -- Posted via http://www.ruby-forum.com/.
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] =>
2008 Aug 27
11
find_by_sql and xml_serializer problems
Hi, I''m doing a find_by_sql and am getting an odd error when trying to render the result to xml. The find is: children_list = find_by_sql("SELECT components.componentid, components.logicalname, versions.level, versions.branch, versions.sequence FROM components, versions where components.componentid = ''" + component_id + "''" + " AND
2011 Dec 07
5
Find_by_sql help?
How to make it work with paginator (kaminari)? MySQL and full text search: Words (id, word) @words = Word.find_by_sql(["SELECT id, word, MATCH (word) AGAINST (?) AS Score FROM words WHERE MATCH (word) AGAINST (?) ORDER BY Score Desc, word!=?", params[:search],params[:search],params[:search]]) I can''t add .page(params[:page]).per(5) to the end of "find_by_sql()" so
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
2009 Jul 23
1
How can I paginate records find by using find_by_sql
Hello everyone, I forced to use @user = User.find_by_sql sql_query in a particular situation in my project. Now I want to paginate the records. How can I paginate the records? Please help me. Thanks in advance -- Posted via http://www.ruby-forum.com/.
2006 May 23
3
Pagination problem
hi everybody, i am new to rails.. plz clear my doubt... this is my question In my table(public_topics), i have 11 rows of data.. whenever i run the following view, it shows the entire rows in the current page.. and i have set the '':per_page'' option to ''2''.so it must show two data per page..but it shows all the rows in a single page..and this case continue
2006 Jan 27
5
Newbie:Adding a new Table-Strange Error
Hi Everybody, I am a newbie in this list so please forgive me if this is a lengthy message. Currently I am working on a project at my work place that includes viewing some oracle tables(I do not have control over to rewrite the tables) and searching the tables based on a given criteria with Rails. Up untill now everything was working great. The database consists of a lot of tables but I was
2010 May 07
1
undefined method 'find_by_sql'
Why would I get an undefined method `find_by_sql'' for #Example: 0x981a4e4> for error when trying to use the find_by_sql method in my model? def init_dictionaries tables = find_by_sql( "SHOW TABLES FROM thesaurus" ) @@tables = tables.collect{ |t| t.Tables_in_thesaurus } end -- You received this message because you are subscribed to the Google Groups "Ruby
2006 Jan 30
9
error when adding a new table to the existing application
Deniz wrote: > Hi Everybody, > I am a newbie in this list so please forgive me if this is a lengthy > message. > Currently I am working on a project at my work place that includes > viewing some oracle tables(I do not have control over to rewrite the > tables) and searching the tables based on a given criteria with Rails. > Up untill now everything was working great. The
2006 Jan 26
1
Help constructing a find_by_sql command
Hello all. I am trying to do the equivalent of: @componentlogs = Componentlog.find(:all, :conditions => [ "cl_compname like ?", @criteria ], :offset => offset, :limit => items_per_page, :order => "cl_spr DESC" ) in a find_by_sql statement. I cannot use the build in because the adaptor isn''t quite right (OCI8) When I use it I get the following error