Displaying 20 results from an estimated 3000 matches similar to: "Inner SELECT-s in Rails"
2010 Jun 10
1
Can RMySQL be used for a paramterized query?
I have not found anything about this except the following from the DBI
documentation :
Bind variables: the interface is heavily biased towards queries, as opposed
> to general
> purpose database development. In particular we made no attempt to define
> “bind
> variables”; this is a mechanism by which the contents of R/S objects are
> implicitly
> moved to the database during SQL
2007 Dec 12
2
possible bug in eager loading
Hello,
@users = User.find(:all, :include => {:user_data =>
:user_data_field}, :order => "username = ''someone-oHC15RC7JGTNLxjTenLetw@public.gmane.org'' desc",
:limit => 50)
This produces:
User Load IDs For Limited Eager Loading (74.648762) SELECT * FROM
(SELECT DISTINCT ON (users.id) users.id, username AS alias_0 FROM users
LEFT OUTER JOIN
2005 Dec 19
3
created_on, created_at defaulting to 2000/01/01 00:00:00
Hello all,
Rails 1.0.0
created_on is being set to 2000/01/01 00:00:00
Any ideas on this ?
Thanks!
Schema is
create table user_login_history (
id int identity(1,1) not null,
user_id int not null,
created_on datetime default(getdate()) not null,
created_at datetime default(getdate()) not null,
updated_on datetime default(getdate()) not null,
constraint pk_user_login_history primary key clustered
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
2009 Oct 11
1
passing model data to a plugin called within that model
I am making a plugin which extends ActiveRecord::Base
I have the plugin working in my models in other aspects. I would like
to pass in some data to the plugin, but I can''t get the data I would
like.
so if I have:
class Stuff < ActiveRecord::Base
belongs_to :thing
my_plugin :id => self.thing.other_id
end
it chokes on figuring out what to do with self.thing.other_id.
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
2006 May 23
3
ez-where headscratch
Hi there,
I''m puzzled by this apparently simple query I can''t manage to reassemble
using ez_where plugin.
cond = Caboose::EZ::Condition.new :my_table do
start_on < Time.now
any {end_on > Time.now; end_on.nil?}
end
I keep getting the following result :
>> cond.to_sql
=> ["my_table.start_on < ? AND (my_table.end_on > ?)", Tue May 23
2005 May 19
5
[OT] Sqlite2 question
So, under Sqlite2, if I want to update a database''s schema, I have to
dump the DB, modify the table''s structure, then go and modify EVERY
insert statement.
The insert statements look like (from memory):
INSERT INTO my_table VALUES (''some_id'', ''some_val'', '''', '''', '''',
''some_other
2009 Oct 01
1
Help me replace a for loop with an "apply" function
...if that is possible
My task is to find the longest streak of continuous days a user participated
in a game.
Instead of writing an sql function, I chose to use the R's rle function, to
get the longest streaks and then update my db table with the results.
The (attached) dataframe is something like this:
day user_id
2008/11/01 2001
2008/11/01 2002
2008/11/01 2003
2006 Jun 22
3
best way to generate sums of groups
I''m a rails newby, so I''m trying to wrap my head around how to tackle
this, since my first few attempts failed.
Let''s say your database looks like this:
Users
id, name, created_at
Points
id, user_id, value, created_at
Users complete different tasks and are awarded varying levels of points,
which are recorded in the Points table. What if you wanted to display a
2011 Apr 07
2
Selecting data from list object
Hello Group,
Is there a simpler way to get data out of a list object? (like in data
frame without using the apply functions)
I have the following dataset
> dput(d)
list(c("20110405", "092102"), c("20110405", "092538"), c("20110405",
"093458"), c("20110405", "101124"), c("20110405", "102041"),
2011 Apr 11
4
Printing field attributes outside the model.find_by_sql
Hi All,
I have Model called pays..and it has fields like(id, topic, subject,
created_at, b_id) and i also have a Model called suggests with
fields(id, income, price, b_id)
In my ruby on rails action or method Controller:
def print_two_table
@p = Pay.find_by_sql("SELECT p.id, p.topic, s.id, s.income, s.price FROM
pays as P LEFT OUTER JOIN suggests AS s ON s.b_id = p.b_id WHERE
2007 Aug 30
1
belongs_to with foreign keys that reference non primary key columns
Hello,
I have a situation where the foreign key into a table doesn''t
correspond to that table''s primary key:
my_table
-------------
id (pk)
name
...
other_table
--------------
id (pk)
my_table_name (fk references my_table(name))
...
I want to be able to say something like:
class OtherTable < ActiveRecord::Base
belongs_to :my_table, :foreign_key => { :my_table_name
2010 May 25
1
find_by_sql timestamp parameter
Hi
In controller I have this query:
@price_stat = Price.find_by_sql("select id, cost, tour_id,
unix_timestamp(created_at) from prices")
when I try to display result''s created_at column I don''t have any
results:
<% @price_stat.each do |p| %>
<p><%= p.created_at %></p>
<% end %>
result is empty
But if I try without unix_timestamp. ie:
2006 Feb 03
2
JavaScript Prototype Help?
I have a form with a text area. I want to have an observer watch the
text area and update a div with the running count of characters in
the text area. I tried "onchange" but that doesn''t update until you
leave the text area. I was able to get it working using AJAX, but
it''s silly to make a needless round trip to the server, when the page
already knows
2008 Dec 05
2
Asterisk h323 module
Hello!
I have a problem with build astersik-addons-1.4.7 on Solaris 10. When I
tried to do "make" I got such error:
*
chan_ooh323.c: In function `reload_config':
chan_ooh323.c:2053: error: `IPTOS_MINCOST' undeclared (first use in this
function)
chan_ooh323.c:2053: error: (Each undeclared identifier is reported only once
chan_ooh323.c:2053: error: for each function it appears
2006 Apr 18
3
ez_where query question
I''m having fun composing queries with ez_where, but am stuck on how to
formulate the following using the ez syntax:
(begin_date >= ? OR end_date >= ?) AND (description LIKE ? OR name LIKE ?)
There are two clauses, each containing OR operators (the ez ''any'' syntax)
but both clauses must evaulate to true for a match.
Can anyone suggest the proper way to construct
2006 Apr 06
6
pagination question
i''ve figured out how to use the next and previous links with the
paginator class but now i''m trying to figure out how to display all the
page numbers in between. looking through the rails api, i found
paginator.each() but i''m not sure how to use it, or if that''s even what
i am looking for.
also, is there a way to limit the amount of pages like some sites
2007 Dec 23
11
return day from date (javascript) ?
Ok, I know this isn''t a Rails problem, but if you could help me out
that''d be brill.
I''ve used JavaScript to create a new Date object containing a date of my
choice...
mydate = new Date("11/24/2007");
//going with Javascript''s mm/dd/yyyy format
now this is good, what i want to do now is put in an integer variable
the number for the day, in this case
2007 Jan 23
7
Ajax
Hi, I need some help. I`m developing a data base administrator using
ruby and ajax, both for the first time and I have a problem:
I have a form where you can add or delete some information about a
person., information related with their studies. There is no problem
when I add, but when I delete, it deletes from the database but when I
try to save it throughs me an error because it tries to find