0

I'm struggling with my Ruby on Rails App that has a legacy database. It works in general but now I'm trying to show the associations created in the database.

The two relevant scaffolds are called repo and build.

One repo has many builds - so I have a foreign key repo_id in my builds table.

The problem is the following:

  • calling repo/7 in browser is working
  • calling repo/7/builds/8 is also working
  • but if I call repo/7/builds my system is crashing down ;)

Furthermore I can do that in the rails console without any problems, like that:

r = Repo.find(7)
r.builds 

--> returns all builds belonging to repo with id 7

Does anyone know what's going wrong here? Thanks in advance!

cruxi
  • 819
  • 12
  • 28
  • Would you mind sharing your routes.rb file, specifically the section dealing with those two resources? Also, what error is returned to you when attempting to call repo/7/builds ? – Chazu Nov 18 '12 at 19:14
  • of course, the root: `resources :repos do resources :builds end` when I try to call repo/7/builds nothing happens. Even not in the console. The page is just loading for about 10 minutes and then the browser crashes down. – cruxi Nov 18 '12 at 20:53
  • Hrm, the route looks correct, and the manner in which it fails is hardly helpful...Any more information you can give us about the nature of the legacy database, or any code from your models or controllers which you're able to share would be helpful as well... – Chazu Nov 18 '12 at 21:24
  • what does your webserver logs say? – BvuRVKyUVlViVIc7 Nov 18 '12 at 21:49
  • I found out whats happening when calling `repo/7/builds` The system is not really crashing down but it tries to load **ALL** builds (about 100 000 lines) and not only the relevant ones for repo 7. Could there be a problem with rails predefined descriptions for id or the foreign key? These are my associations: `belongs_to :repo, :foreign_key => "repo_id"` --> in events `has_many :events`--> in repos I have attr_accessible for the foreign key and the id's for both tables as well. – cruxi Nov 19 '12 at 10:13
  • sorry, markdown for line breaks is not working :/ – cruxi Nov 19 '12 at 10:18
  • Thanks guys for your help, I found out that I didn't change anything in the controllers and that was the problem! – cruxi Nov 19 '12 at 16:30

0 Answers0