similar to: Include with two references of one model of the same table

Displaying 9 results from an estimated 9 matches similar to: "Include with two references of one model of the same table"

2007 Oct 15
2
Association Help , 2 Teams playing a FootballGame
So I have the models class FootballGame < ActiveRecord::Base end and class Team < ActiveRecord::Base end I want to be able to do something like this @t1 = Team.create(:name=>"Michigan Wolverines football") @t1.save @t2 = Team.create(:name=>"Penn State Nittany Lions football") @t2.save @g = FootballGame.create(:hometeam => @t1, :awayteam => @t2) @g.save
2007 Oct 16
8
Using multiple foreign keys in views
I have a model, Game, that has_many :teams. There''s a home team and an away team. I created two foreign keys, so each game can have two teams associated with it. Here''s the Team model: class Team < ActiveRecord::Base belongs_to :game, :class_name => ''Game'', :foreign_key => ''hometeam_id'' belongs_to :game, :class_name =>
2006 Jan 18
3
retrieving value from select
In my view, I have: <%= select("division_filter", "division_id", Division.find_all.collect {|p| [ p.division, p.id ] }, { :include_blank => true }) %> How do I retrieve the division_id in my controller? -- Posted via http://www.ruby-forum.com/.
2007 Aug 04
1
ActiveRecord gotcha with references?
I have this situation: class Employee < ActiveRecord::Base belongs_to :designation end class Designation < ActiveRecord::Base end I do the following at the irb console: Step 1: Find an employee >> emp = Employee.find 3 => #<Employee:0x35a7d34 @attributes={"designation_id"=>"3", "id"=>"3",
2006 Aug 03
5
Strategy for persisting row filter variables in pagination?
I have my list view filtering rows shown within the table <tr> tags like most of the introductory tutorials do. As I''m adding a few dozen entries I''m noticing the standard scaffolding pagination doesn''t pick up the number of rows from the filter since it is not being passed the number of rows returned within the scope of the filter statement. >From a
2008 Feb 15
3
Destroy, dependent and performance
Hi! This is my first post in this forum. I''m learning RoR for two weeks and I''m very interested about how to improve this framework. I was testing one app I''m working in and I had some problems with destroying. The code is simple (and maybe wrong, as I said i''m just learning!). When you destroy a league, you send a message to all the users associated to this
2009 Apr 21
2
validates_uniqueness_of
hello all, i am new to RoR programming and am struck with the functional test whole checking for uniqeness of carriers. If it is not unique,the the bin shudn''t be created.Can someone help me in correcting my code. def test_create_failure_cycle_unique begin num_bins = Bin.count post :create, {:bin => { :carrier => carriers(:A), :cycle => cycles(:one), :name =>
2006 Jan 24
4
How to filter an activerecord find_all...
I have a nice hierarchical table structure like this: divisions has_many groups groups belongs_to division has_many subgroups subgroups belongs_to group has_many units units belongs_to subgroup I have a report which is based on units, but i want to be able to filter the units by which subgroup, or which group, or which division. I also want to sort them by division.name,then group.name,
2008 Jun 15
7
Getting "no block given" on find method - rails 2.1
I am trying to do a simple find through the current_user but get an exception. Either someone spiked my Starbucks coffee and I am screwing up all over the place or there is something wrong. def index @league = current_user.leagues.find(13) end # Error LocalJumpError in Admin/schedule todosController#index no block given If I pass a block to it it works fine, but it is just messy: =====