Displaying 20 results from an estimated 1000 matches similar to: "Filter on variable"
2006 Jul 25
6
Subtract a field from the current time in MySQL?
I have the following:
Table Products:
With a column called "purchased_at" of type "datetime".
Products.find(:all, :conditions => ["? - purchased_at >= 120",
Time.now])
Why doesn''t that work? What I''m trying to do is find records that were
purchased less than or equal to 2 minutes ago.
Thanks for your help.
--
Posted via
2005 Dec 08
2
Confusing lock problem in rails
I have a model class in rails that has a class variable that is a
ferret index. For some reason, the methods in my class that refer to
the class variable are getting lock conflicts. Can anybody see any
obvious reason why? I notice that it keeps leaving a lock file in the
index directory. I thought auto_flush was supposed to remove the lock
automatically after every operation. Is there
2006 Jan 31
1
Updating :has_many - :through related items
Hi,
I''ve got my little app working pretty well. I''m using pretty much the
model and table layout from my previous thread, as suggested by Bill
Katz:
<http://www.ruby-forum.com/topic/52506#26260>
I have the Create page working and a delete Match page working, which
along with the appropriate record in the Matches table, removes the
linked items in the competitions table.
2009 Jul 29
5
[newbie] double relationships in database
I have the following tables
teams
id :string
name :string
and
matches
id:
home_team :team_id
visitor_team :team_id
how can I reflect that kind of relationship in a RoR model?
thanks and keep up the good work.
2006 Apr 03
2
HABTM migrations
Bad rails day for Matt-
In a migration, for a habtm:
create_table :teams_users do |t|
t.column :team_id, :integer
t.column :user_id, :integer
end
Ok, fine. In a controller (well really a migration script):
@user.teams << Team.find( 3 )
And the SQL pumped at my server is:
INSERT INTO teams_users (`team_id`, `id`, `user_id`) VALUES (3, 3, 34)
Which
2006 Feb 15
1
Per Database Migrations
Is there away to have parts of a migration file only work with a specific database. For example I am inserting some data into a table with:
execute "INSERT INTO demo_lists(position, name, updated_at, created_at) VALUES (1, 1, ''scott'', CURDATE(), CURDATE());"
Of course the curdate() function may only be available on mysql. So can we some how determine which
2006 May 04
3
Date find help please.
Here''s my problem.
I have an ''Item'' model with a date column called "inserted_on" formatted as
"yyyy-mm-dd hh:mm:ss:t". I want to find all records that were inserted more
than 30 days ago. How would I say that using the Item.find ( :all .....)
method? I don''t fully understand the syntax. I tried
@result = Item.find( :all, :conditions =>
2006 May 31
5
undefined method `redirect_to''
Hi all
I have followed this tute:
http://hivelogic.com/articles/2005/12/01/ruby_rails_lighttpd_mysql_tiger
to get rails running and all is fine except for getting:
undefined method `redirect_to''
when I load my test page.
I have the following in my xx.rhtml:
<%= select :group, :user_id, find_all_groups, {}, {:onclick =>
select_group, :size => find_all_groups.size + 1}
2009 Jun 25
7
Join Tables
I just have a few questions about join tables. From my understanding
the following applies (correct me if I''m wrong):
1.Join tables are always named with the names of the two associated
tables, in alphabetical order, separated by an underscore.
2.The foreign key fields are named with the name of the table they are
referencing, with _id appended.
3.The foreign key is referencing a
2006 Jul 26
8
team captain - habtm w/has_one...
the below...
class User < ActiveRecord::Base
has_and_belongs_to_many :teams
class Team < ActiveRecord::Base
has_and_belongs_to_many :users
has_one :captain, :class_name => ''User''
produces the error...
Mysql::Error: Unknown column ''users.team_id'' in ''where clause'': SELECT *
FROM users WHERE (users.team_id = 1) LIMIT 1
i
2008 Jan 27
4
(REST) Nested routes
Hello, I''m in troubles with nested routes. I have three models: Team,
Tournament and TeamTournaments
class Team < ActiveRecord::Base
has_many :tournaments, :through => :team_tournaments
has_many :team_tournaments
class TeamTournament < ActiveRecord::Base
belongs_to :team, :foreign_key => ''team_id''
belongs_to :tournament, :class_name =>
2010 Oct 03
4
USB boot: No DEFAULT or UI configuration directive found!
Hi, friends
It is described at this page:
http://superuser.com/questions/195275/usb-boot-no-default-or-ui-configuration-directive-found
<http://superuser.com/questions/195275/usb-boot-no-default-or-ui-configuration-directive-found>help,
thanks!
--
regards
chenge
2009 Jul 16
9
Please help me understand how arrays are translated in rails
I''ve spent hours researching the subject and have tried many test
sequences in IRB, and rails console but I''m just having trouble making
headway into what is probably a very easy subject.
I understand arrays with at least 4 other languages but with Ruby I
haven''t found a mental connection with how I can assign variables to
arrays..
Take for example:
def
2006 Jan 23
15
Looking for DB/Model Design Suggestions
Hi,
I''m working on an app - my first Rails - and am looking for some
suggestions on the best way (or good way) to set up my models / DB. In
general there are teams and matches; a team will participate in multiple
matches, and in each match there will be 6 teams - 3 vs. 3.
I''m going to want to be able, for a particular team, pull up all matches
for that team, to display a
2006 May 14
3
Strange Database Mapping Question
Dear Rails List,
I am new on the list so will assume straight away that this question has been
answered before. As I can see no immediate way of searching the list, I will
ask the question. I apologize in advance for any disruption this may cause.
Question time:
I am trying to write a web application for the staff at my office to play a
form of virtual Super14. Its a bit like any of the
2005 Dec 31
6
habtm recursion via destroy_without_callbacks
I am having a problem with two models that each have a HABTM
relationship to the other. For example:
CREATE TABLE people (id INT, name TEXT);
CREATE TABLE teams (id INT, name TEXT);
CREATE TABLE people_teams (person_id INT, team_id INT);
The person model has:
has_and_belongs_to_many :teams
And the team model has:
has_and_belongs_to_many :people
The trouble comes when trying to destroy
2006 Apr 16
1
Design question: Years/Teams/Students
People,
I want to design a historical sports db for my old school. I think at
the moment it should be like:
A year has many teams
A team has many students
A student has one lastname, firstname and middlename
but a student can also have many teams (eg summer/winter abd over a
number of years) . .
Is there a problem with this? Doesn''t it just mean that there will be a
student table
2008 Sep 17
0
permalink_fu and classes with different primary_key than id?
Has anyone else had problems with this scenario?
class Team < ActiveRecord::Base
# Primary key
self.primary_key = ''team_id''
has_many :players, :foreign_key => :team_id
has_permalink :city, :param => true
end
I am getting all kinds of trouble - that goes away if I comment out
the has_permalink declaration.
With PermalinkFu:
>> fs = Team.new
=>
2009 Jul 17
19
I need help saving table data from a rake task
I need to find out how I can create and save a large dataset to a table
based on multiple returned arrays from a Rake task.
Here is my example using just two arrays (there are 14 in this
particular rake task):
update_tsos_offense = TsosOffense.new
to_team_id, to_ppcs = update_tsos_offense.calculate_tsos(TotalOffense,
"ydspgm", "desc")
ro_team_id, ro_ppcs =
2010 Jan 25
0
has_many, :finder_sql, setting attributes
Hi all,
My question is somewhat complicated, but bear with me. My project has a
number of models: User, Program, and Team. Users belong to multiple
Programs. Programs have multiple teams, but Teams belong to one
program. For each Program a User belongs to, he can belong to multiple
Teams. (Think of this in an athletic context where users are athletes,
programs are universities). So my