Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error Class 'office' does not exist or contains a syntax error and could not be loaded. #1

Open
cuzic4n opened this issue Feb 18, 2010 · 1 comment

Comments

@cuzic4n
Copy link

cuzic4n commented Feb 18, 2010

http://patshaughnessy.net/2010/2/13/creating-associations-to-existing-data-part-2-belongs_to-with-auto_complete
.
.
once I got to here..
cuzican@CUZIVISTA ~/gitrepo/test
$ script/generate scaffold_for_view employee name:string --view belongs_to_auto_complete:office
warning Model Office does not contain a has_many association for Employee.

cuzican@CUZIVISTA ~/gitrepo/test
$ vi app/models/office.rb

i then added the has_many association.. then i got the below

cuzican@CUZIVISTA ~/gitrepo/test
$ script/generate scaffold_for_view employee name:string --view belongs_to_auto_complete:office
error Class 'office' does not exist or contains a syntax error and could not be loaded.

I tried changing office to Office and then spent all kinds of time trying different variations of the has_many.. plural.. not.. looking at my rails env.. etc.. and I wasted a bit of time because I was too stupid to notice that I was adding the has_many as follows:
has_many employees
when i should have added it as "has_many :employees" .. damn colon..
added that colon and all was well.. since you do such a good job checking for things I figured I should let u know this one so you could add a check in it and save others headaches.. or not.. ;->

p.s. nice work.

@patshaughnessy
Copy link
Owner

Thanks for trying view mapper! Hmm this is a tough one; I can see how helpful it would be to display Ruby syntax errors but I'm not sure how to do that right now. I'll do some reasearch and see if I can find a way. Right now view mapper displays that message if the class doesn't exist... which could be if you never wrote it or if Ruby returned an error trying to load it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants