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

  • SEARCH
  • Home
  • 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 5982481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:05:36+00:00 2026-05-22T22:05:36+00:00

I got a form that have a nested link. The problem that the link

  • 0

I got a form that have a nested link. The problem that the link field is empty on edit.
Here is my form:

<h1>Editing kategori</h1>
<%= simple_form_for(@konkurrancer, :url => {:action => 'update', :id => @konkurrancer.id }) do |f| %>
    <%= f.simple_fields_for :link_attributes do |d| %>
    <%= d.input :link, :label => 'Tracking url', :style => 'width:500;' %>
    <% end %>
    <%= f.button :submit, :value => 'Edit konkurrence' %>
<% end %>
<%= link_to 'Show', admin_konkurrancer_path %> |
<%= link_to 'Back', admin_konkurrancer_path %>

My konkurrencer model:

has_one :link

My link model:

class Link < ActiveRecord::Base
belongs_to :konkurrancer
accepts_nested_attributes_for :konkurrancer
end

My konkurrancer edit action:

  def edit
    @konkurrancer = Konkurrancer.find(params[:id])
    @konkurrancer.link_attributes.build
  end
  • 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-22T22:05:37+00:00Added an answer on May 22, 2026 at 10:05 pm

    1) Remove from your Link model

    accepts_nested_attributes_for :konkurrancer
    

    and add to your Konkurrancer model

    accepts_nested_attributes_for :link
    

    2) In controller edit action remove

    @konkurrancer.link_attributes.build
    

    and in controller new action add

    @konkurrances.build_link
    

    3) In the view file replace

    <%= f.simple_fields_for :link_attributes do |d| %>
    

    with

    <%= f.simple_fields_for :link do |d| %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a situation where I have a main form that pops up an
I have a contact form that sends to my email and I recently got
I've got a form that's a few pages long. To traverse the form all
I've got a sign up form that requires the user to enter their email
I've got a submission page in php with an html form that points back
I've got a form inside an <asp:Content> block that is being submitted to a
I've got some code that will generically get all Controls in a form and
I've got a form where I have two radio buttons and two interchangeable controls
I'm having a problem with nested model forms that contain radio buttons, when I
Here's a tough one for you: I have a NotesForm object and I got

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.