Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6201327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:32:00+00:00 2026-05-24T04:32:00+00:00

I have a model Issue and a nested Model Relationship In the issue.rb I

  • 0
  • I have a model “Issue” and a nested Model “Relationship”
  • In the issue.rb I have mentioned:

    has_many :relationships, :dependent => :destroy
    accepts_nested_attributes_for :relationships, :allow_destroy => true
    
  • In relationship.rb I have mentioned:

    belongs_to :issue
    
  • Following Ryan Bates Railcast#196 I have the following in my issues_controller:

    relationship = @issue.relationships.build
    

However, I am encountering an error “unknown attribute: relationship”

Am I doing something incorrectly here? I do see the Relationships Attributes being passed to the server in the log however, this error does not let the create to be successful.

My expertise with rails is beginners level so kindly excuse me if I am asking a question which maybe deemed trivial.

Thanks for the help.

EDIT: The relevant Controller code:

    @relationship = @issue.relationships.build
    #@relationship = Relationship.new(params[:relationship])
    if @relationship.issue_id = ''
      @relationship.issue_id = @issueid
    end

    if @relationship.cause_id = ''
      @relationship.cause_id = @issueid
    end

    @relationship.save
    redirect_to(:back, :notice => 'New Relationship was created') 

What I see on the trace:

    ActiveRecord::UnknownAttributeError in IssuesController#create
    unknown attribute: relationship

Among the Issue parameters, I see the Relationship params being passed as expected:

    "relationship"=>{"issue_id"=>"100",
    "cause_id"=>""}

ANOTHER UPDATE
Posting the form_for code:

    - form_for Issue.new do |f|

      .field  
        = f.text_field :description, :class=>"formfield", :id=>"frm_descr"

      .field  
        = f.hidden_field :wiki_url, :class=>"formfield", :id=>"frm_wiki_url"

      .field
        = f.hidden_field :short_url, :class=>"formfield", :id=>"frm_img_url"

      .field
        = f.hidden_field :title, :class=>"formfield", :id=>"frm_title"         

      = f.fields_for :relationship do |builder|
        = builder.text_field :issue_id, :class=>"form_field", :id=>"frm_rel_issue_id", :value=>@issue.id 
        = builder.text_field :cause_id, :class=>"form_field", :id=>"frm_rel_cause_id"

      .actions
        = f.submit 'Create', :class=>"save_button", :name=>"save_issue_rel_button", :id=>"val_collector"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:32:01+00:00Added an answer on May 24, 2026 at 4:32 am

    Change this line

    = f.fields_for :relationship do |builder|
    

    to this:

    = f.fields_for :relationships do |builder|
    

    Your issue has_many relationships – plural. That will give you the correct relationships_attributes parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model, Thing, that has a has_many with ThingPhoto, using Paperclip to
I have the same issue as Creating an additional related model with Devise (which
I have a Forum model, whose instances can have many nested forums: class Forum
I have the issue that i have a viewmodel (MasterViewModel) with a nested viewmodel
Here is the situation. I have some ViewModels that contain nested complex model types.
I have a model Foo and a model Bar, both of which has_many :bar_foos
I have a code first model: namespace InternetComicsDatabase.Models { public class Issue { [Key]
I have a very simple issue: User model: class User < ActiveRecord::Base devise :database_authenticatable,
I have two models nested with accepts_nested_attributes_for : class Place < ActiveRecord::Base # Relations..
I have a model being populated by my data layer and then I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.