Displaying 20 results from an estimated 30000 matches similar to: "Does content_columns hold related data from other tables?"
2006 Mar 08
2
Displaying related tables in forms.. probably an easy question!
Hey All,
I have two tables.. One belongs to another. Why can''t I reference
table1.table2.attribute?
Specifically, using scaffolding:
property.rb -
has_one :PropertyType
property_type.rb -
has_many :Properties
property_controller -
def list
@property_pages, @properties = paginate :properties, :per_page => 10
end
list.html:
1. <% for property in @properties %>
2.
2006 Mar 09
0
Re: Displaying related tables in forms.. probably an easy qu
Steve -
That was the issue.. It seems obvious now, but I needed to reference
Property.PropertType.name instead of property.propertytype.name
Thanks!!
Brian
-----Original Message-----
From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Steve
Koppelman
Sent: Wednesday, March 08, 2006 5:00 PM
To: rails@lists.rubyonrails.org
Subject: [Rails] Re:
2006 Jan 03
0
Automatically mapping content_columns?
Hi all,
Quick setup - I''ve got a table Foo. Foo has a foreign key (bar_id) to the
table Bar. The Bar table has an "id" and "name" column. Assume a 1:1
relationship.
The issue I''m trying to resolve (or rather, be lazy about) is with regards to
Foo.content_columns. By default it doesn''t pickup the foreign key. What I''m
wondering is if
2006 Apr 15
7
New to rails - scaffold command , how to get related items?
Ahoy,
I was able to follow the tutorials and build a simple to-do list program
with Items and Categories and have the related tables link up w/ the
default "scaffold :Items" command plus custom defenitions.
Then I erased all of that and tried rebuilding the program using the
ruby script/generate scaffold Item (and category) command.
Now the templates look like
"
<% for
2006 Mar 31
3
Complex Through Statement
Quick Overview:
I have an ''Employee'', some ''Merchants'' and some ''Products''. A
''Merchant'' has many ''Products''. An ''Employee'' has multiple ''Merchants'',
depending on their relationship. For example, the Employee may be the
enrollment contact for one merchant and the
2006 Mar 12
3
Newbie: using find like a sql join query
I have a working Rails app with several related tables, but can''t find
an answer to this question in the Dave Thomas Rails book. Imagine for
example:
table departments with columns: id, department_name
table employees with columns: id, department_id, employee_name
and of course the employees table has a constraint foreign key
(department_id) references departments(id)
So this is
2006 Jan 25
1
Rails day 2: where is my association?
I?m following along a few tutorials on the web and trying to implement
my own example, but I must be missing something because I can?t get
has_many or belongs_to to work like I expected. now I have watched all
the videos and made a cookbook several times with different interfaces.
what I''m looking for is *not* a code snippet to solve something (because
I already have that),
2006 Feb 03
1
Only iterating over the middle content_columns?
Standard behavior for the list action is to use content_columns to get
all the fields of a model and then do something with them. I''d like to
ignore some of them and iteratre over the rest. For instance I may have
A B C D ... X Y Z and I''d like to do something special with A and B and
then Y and Z, but in the middle I''d definitely like a loop to say
2010 Dec 23
0
has_many :through full stack help
I am trying to implement HMT for the first time and having a ton of
trouble. I would like to be able to have the user check a checkbox
and fill some extra fields for data input. I have tried so many
iterations borrowed from different places I found on the web, none
seem to work quite right. Essentially I have two models: ''practice''
and ''system'' where a
2006 Apr 26
2
two layers of has_many
Hi,
There are many companies. Each company has many departments. Each
department has many employees. The following find_by_sql method seems
awful. What is the best way to get all the employees of a company?
class Company < ActiveRecord::Base
has_many :departments
def employees
Employee.find_by_sql("SELECT employees.*
FROM companies, departments, employees
2006 Jan 21
0
Display options from HABTM
I have a large certifications table that I would like to have a little
more controll over, it is part of a HABTM relationship.
-----------------------------------
db''s (simplified)
>certifications
id
course
>employees
id
department_id
type_id
name
>departments
id
name
>types
id
kind
>certifications_employees
certification_id
employee_id
2006 Aug 04
2
problem eager loading with sti
Here''s the setup (working off Rails 1.1.4):
Class Project
belongs_to :employee
Class Employee < Person
has_many :projects
When I try to paginate(:employees, :include =>
:projects) I get the error "Association named
''projects'' was not found; perhaps you misspelled it?"
I can :include other models that the Person class
has_many or habtm of, and if I
2006 Mar 13
3
validates_associated problem
Hello,
I have a situation where an ''employee'' belongs to a ''department'' and
have setup the relationship as follows.
class Employee < ActiveRecord::Base
belongs_to :department, :foregin_key => "department_id"
validates_associated :department_id
end
class Department < ActiveRecord::Base
has_many :employees
def validate_on_update
2005 Jul 07
3
NameError Exception
Ruby/Rails n00b here so go easy on me...
I''ve been wracking my brain trying to figure out what is wrong here.
I''ve checked all my models for the appropriate belongs_to, has_many,
etc. I''ve checked to make sure I''m using singular and plurals in the
right spot. I''ve checked my syntax around all my "within"''s and nothing
seems to fix
2005 Sep 17
1
Export to Excel
I need to export some data to an Excel file and found
a reference in the HowTo section of the Rails Wiki.
Followed it to the letter: added "export" action to
controller, copied export.rxml and changed in
accordance to model.
When I call the export action I keep getting
"undefined method `content_columns'' for #<Employee".
The ActiveRecord mention content_columns
2008 Mar 12
1
Ordering across related tables
I have two related tables: groups and categories. In the models,
Group
has_many "categories"
Category
belongs_to :group
Category does have a column, "group_id" as required.
Both the groups and categories tables have a "sortorder" column which
dictates the order the items are to be presented.
In my controller, I want to retrieve the Categories
2008 Apr 21
1
Urgent ActiveRecord has_many Problem - Please Help
Hi Guys,
I''ve been looking everywhere for an answer to this but so far without
success.
I have three models:
1) employees
has_many :memberships
has_many :projects, :through => :membership
2) projects
has_many :memberships
has_many :employees, :through => :membership
3) membership
belongs_to :employees
belongs_to :projects
Membership is used to join employees
2009 Oct 20
2
Find sub sub records
Hi everyone, I have the following problem, maybe someone can help me
figure out what to do.
To simplify my situation, I''m going to make an example of what I need,
this is not the real app structure.
Let''s suppose we have three models, Library, Author, Book.
Manager
has_and_belongs_to_many :area_managers
AreaManager
has_and_belongs_to_many :managers
has_many :employees
2006 Jun 23
0
Overriding a file_column attribute in model
I have a user model subclassed into Employees and Managers using STI. I
am using FileColumn to manage images, in this case logos. If an Employee
doesn''t have a logo of its own, I want my app to use the Manager''s logo
in views.
I did the following in models/users.rb:
-------
class User < ActiveRecord::Base
file_column :logo
end
class Employee < User
belongs_to
2006 Jun 09
0
Calculations based on multiple tables
Hi there,
I''m trying to grab all the contest_entries from a particular contest, and
then grab all the appropriate contest_ratings associated with the songs and
contest. The end result is an average score for each song involved in each
contest.
I made an ERD of my table structure which can be found at:
http://antrover.com/erd/contest_question.jpg
Here''s my model structure: