Cannot get this nested form with has_one associatoin to work?

Actually, since the Cities already exsit, I think there is no need for nested forms here. Try Replacing With Updated afters comments Could you change your relationship with (and update database scheme accordingly) class User.

Yeah, it was my first approach too. But this gives this error: City(#37103820) expected, got String(#21183516). Because it will call the .

City method, which expects a City instance. – Tempus Apr 7 at 8:08 Oops, just realised that you User won't have a city_id Could you change your relationship with (and update database scheme accordingly) class User – LapinLove404 Apr 7 at 8:08 Yes, I know that reversing the relationship works, I was just curious why nested forms only seem to work for creating new associations, and not for finding existing ones. – Tempus Apr 7 at 9:37 Nested forms does not only create new associations.It creates the associated objects.

Thinking about it, you can not assign a new user to an existing city since a city belongs_to :user (eash city can thus have only one user). However, you could probably change your form so that it will create a new City with user_id = the new id and name = the selected one from a dropdown collecting names from existing cities with something similar to "name"),:name,:name %> – LapinLove404 Apr 7 at 11:25.

I get this error: undefined method 'city. User_id' for # – Tempus Apr 7 at 7:26 sorry, need to be 'user. City_id' – Sector Apr 7 at 7:48 Still doesn't work.

Undefined method 'user. City_id' for # – Tempus Apr 7 at 7:52 I check this solution – Sector Apr 7 at 8:24 Did you add a city_id field in the User model? – Tempus Apr 7 at 9:52.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions