Advertisement

10.14.2007 at 03:17AM PDT, ID: 22891979
[x]
Attachment Details

Ruby On Rails - Foreign Key Lookup

Asked by cmgtech in Ruby Scripting Language

Tags: foreign, key

I have a one-to-many relationship between a 'file' and a 'directory'.  What I'd like is that in the 'file' scaffolding (maybe view is more appropriate?), a dropdown with all 'directory' listings.  I'm having a many-to-many issue, but I'm hoping that once I figure out one-to-many, I should be able to figure out many-to-many.

The best I can find on the internet show that I put a belongs_to in file model and a has_many in directory model.  How do I take it to the final step and create a dropdown that will allow me to assign directories to files?  

I assume that I modify the 'new' method in the file controller, but I'm having a hard time with syntax.  After modifying the controller, do I have to do anything to the view?

Any help is appreciated, or a website that outlines how to do this.  I have looked around on the web and can;t find anything that spells this out for me.  I'm not much of a programmer so I might not be assuming enough.

Thanks,

Mark

Start Free Trial
[+][-]10.14.2007 at 04:46AM PDT, ID: 20073429

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Ruby Scripting Language
Tags: foreign, key
Sign Up Now!
Solution Provided By: Gertone
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628