I have seen other questions with this problem, but the answer has not worked for me yet. Attempting to register a user, and to create an organization at the same time. . Users and organizations are connected through a work table
Here's my look:
= form_for (resource, as => RESOURCE_NAME, URL: = & Gt; Registration_path (source_name)) | F | = Devise_error_messages! = F.fields_for: organizations do | F | | = F.label: name = f.text_field: name = f.label: email = f.email_field: email = f.label: password = f.password_field: password = f.label: password_confirmation = f.password_field: password_confirmation My Registration Controller:
Class User: Registration Controller & lt; Wise: RegistrationsController DEF New @user = User.new @ user.organizations.build end DEF super end making def Super end end update My organization model:
class organization & lt; ActiveRecord :: Base is has_many: organization_assignments has_many: users ,: through = & gt; : Organization_assignments attr_accessible: name end and my user model:
class users & lt; ActiveRecord :: Base has has_many: organization_assignments has_many: organizations, via = & gt; : Organization_assignments # Include Developing the Default Modules Others are available: #: token_authenticatable, confirmable, #, locked: timeoutable and: omniauthable will: database_authenticatable: registerable: recoverable, rememberable: trackable,: Validatable accepts_nested_attributes_for: # Setup accessible (or secure) properties for organizations: attr_accessible your email: password: password_confirmation ,: remember_me,: organization_attributes # attr_accessible: title, body end I'm getting the error: No large scale assignment Protected Properties: organizations_attributes
You have users To add : associations_attributes to attr_accessible in the model.
Comments
Post a Comment