similar to: I need help saving table data from a rake task

Displaying 20 results from an estimated 100 matches similar to: "I need help saving table data from a rake task"

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
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
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 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.
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 Jun 22
4
Filter on variable
Hi all, I have a question about filtering on a variable. If I have the following code in my controller to select a list of users > @allusers = User.find(:all, > :conditions => [''team_id = ?'', @params["id"], > :order => ''created_at'') Is there an easy way to find out all users who
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 =>
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 Jan 13
2
newbie: access model inside a model
Hi everybody, I''ve started to learn Ruby on Rails with the two books, of course I''m experimenting outside the examples in the book and walking against some things I didn''t learn yet. so here''s the question: Is it possible to access one model from within another? Actually I have a Many to Many relationship between tables and I''m trying to realize
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
2009 Jan 08
5
There is already an object named 'schema_migrations' in the database
I''ve created a table in a SQL Server database using a migration, successfully. I''ve tried to change the name of a column in the table and got the error message above when running ''rake db:migrate''. Previously I have developed using MySQL and Sqlite and migrations have worked successfully. This is an error I have not seen before. Has anybody seen this and worked
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
2008 Nov 10
2
Sort model based on max value of has_many field
Hi, I have models such as: class Team < ActiveRecord::Base has_many :games end class Game< ActiveRecord::Base belongs_to :team end So there are many (well, 0 to 6) games for each team. Team game has a "score". I would like to get a list of the teams, sorted by the highest scoring game - sort of a ranking based on highest score. I''ve tried several cominations of
2006 Jan 09
3
Include with two references of one model of the same table
Hey guys, I just came across this oddity, not sure what to make of it yet, but I think it might be incorrect behavior. When doing a @inst.find(:all, :include => ["hometeam", "awayteam"] ...) hometeam and awayteam are two references from a belongs_to that is of the same model and of the same table. I will get a pgerror stating that "matches", which is
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
2006 Jul 28
2
has_many :through with multiple paths
Hi all. I am currently thinking about how to do the following: I have the following models. Team Person Team has various positions (manager, programmer etc.) I would like each one of those positions to reference one or more Person records. A single Person record could be on 6 different teams at the same time in different roles. the same person could even be on the same team multiple times
2008 Apr 07
7
Saving attribute
Something is getting lost here. def create @home = Team.find_by_user_id(current_user.id) for player in @home.players player.update_attribute(:game_id, @game.id) end end def show @players = Player.find_all_by_game_id(params[:id]) end view <%= @players.size %> # mistakenly equals zero Played with the console and everything should be working fine...
2020 Oct 02
3
Lahman Baseball Data Using R DBI Package
I?m trying to pull data from one table (batting) in the Lahman Baseball database. Notice X2B for doubles and X3B for triples ? fourth and fifth from the right. The dbGetQuery function runs fine when I leave there two out but I get error messages (in red) when I include 2B/3B or X2B/X3B. Can anyone give me some direction? Thanks, Philip Heinrich
2020 Oct 03
1
Lahman Baseball Data Using R DBI Package
The double quotes are required by SQL if a name is not of the form letter-followed-by-any-number-of-letters-or-numbers or if the name is a SQL keyword like 'where' or 'select'. If you are doing this from a function, you may as well quote all the names. -Bill On Fri, Oct 2, 2020 at 6:18 PM Philip <herd_dog at cox.net> wrote: > The \?2B\? worked. Have no idea why. Can