similar to: Updating :has_many - :through related items

Displaying 20 results from an estimated 2000 matches similar to: "Updating :has_many - :through related items"

2006 Feb 05
0
Question about re-using entry form when a validation error occurs
Hi, I think I may be doing more work than necessary. I have a form that is used in both my "New" and "Edit" pages (originally created by a scaffold.) In my form, I have several popups that I have to populate, and if on the Edit page, selects the appropriate entry. To build the popup menus, I''m using: <%= options_from_collection_for_select(@teams,
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
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
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
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
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
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 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
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 =>
2013 Apr 07
1
Remove a row containing a specific value for a column
Dear all, Could anyone help me with the following? DATA <- data.frame(rbind(c("Red1", 1, 1, 1), c("Blue1", 1, 1, 1), c("Red2", 1, 1, 1), c("Red3", 1, 1, 1))) colnames(DATA) <- c("A", "B","C", "D") #Option 1 DATA <- DATA[-2, ] #Same result I would like to achieve with Option 2 #Option 2 - I would like to do
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
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 Jul 02
0
Problem with select, options_from_collection_for_select for selected items
I''m having problems to make the selected works, i''ve been trying with select and options_from_collection_for_select. I''ve tried, :selected, :selected_key, :selected_value, and all i can got from the doc page ( http://rubyonrails.org/api/classes/ActionView/Helpers/FormOptionsHelper.html#M000399 ) and from wiki. Code: select(''informacao'',
2009 Jun 19
0
[PATCH server] add toggable sections to vm form
the vm form is getting cluttered, this patch simply add collapsable sections to the form, making the 'resources' and 'network' sections collapsed by default - icon added - methods added to the js - reorganization / cleanup in rhtml, indentation changes, no functionality or content changes --- src/app/views/vm/_form.rhtml | 109
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 =