Saturday, July 21, 2012

Re: [Rails] Find Company Name not ID

On Sat, Jul 21, 2012 at 4:31 PM, James Harris <lists@ruby-forum.com> wrote:
> I am at a loss why this is not working.....

I'm at a loss as to why you think it should... :-)

> class ContactsController < ApplicationController
> def index
> @contacts = Contact.all
>
> @company = Company.find(@contact.company_id)

What would you expect here? @contact above is not defined in the
code you're showing us.

Are you trying to display the company name of one contact or all?
What is the association between Contact and Company?

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate