Thursday, July 14, 2011

[Rails] Re: Work with two tables in one controller

I have tried in so many ways and can't get it to work. I did something
yesterday that made the app have an redirect loop (too many redirects)
and it took me over an hour just to fix it. So I'm just going to start
all over again.

My initial question had to do with other models but it's basically the
same. I need to do the same for several models. This what I have now.

There are two models: Company and User.
company has_many :users
user has_one :company

routes.rb
resources :companies
resources :users
resources :companies do
resources :users
end

Those routes allow me to do this:
companies/2/users/new

Which is good, but once I submit the form, the app seems to forget the
company_id.

--
Posted via http://www.ruby-forum.com/.

--
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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate