Problem with has_one and nested forms #843

simonc opened this Issue Apr 23, 2012 · 1 comment


None yet

2 participants

simonc commented Apr 23, 2012

With the following code:

# app/models/user.rb
class User < ActiveRecord::Base
  has_one :profile

# app/models/profile.rb
class Profile < ActiveRecord::Base
  belongs_to :user

And here is the form I'm trying to use:

= semantic_form_for @user do |f|
  = f.inputs "Profile", :for => :profile do |profile_f|
    = profile_f.input :some_field

When I call this code I get the same error as in issue #824, profile_id does not exist.

The workaround is to call the following code but I find it pretty ugly :/

= semantic_form_for @user do |f|
  = f.inputs "Profile", :for => [:profile, f.object.profile ||] do |profile_f|
    = profile_f.input :some_field

This is most likely the same problem as #824 that you mention above, so can we please consolidate our efforts there instead? Thanks for documenting the interim work-around. Closing.

@justinfrench justinfrench reopened this Apr 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment