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 8683745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:07:30+00:00 2026-06-12T22:07:30+00:00

I have two models, Developers and Tasks, class Developer < ActiveRecord::Base attr_accessible :address, :comment,

  • 0

I have two models, Developers and Tasks,

class Developer < ActiveRecord::Base
  attr_accessible :address, :comment, :email, :name, :nit, :phone, :web
  has_many :assignments
  has_many :tasks, :through => :assignments
end

class Task < ActiveRecord::Base
  attr_accessible :description, :name, :sprint_id, :developer_ids
  has_many :assignments
  has_many :developers, :through => :assignments
end

class Assignment < ActiveRecord::Base
  attr_accessible :accomplished_time, :developer_id, :estimated_time, :status, :task_id
  belongs_to :task
  belongs_to :developer
end

im taking care of the relation by adding an Assignment table, so i can add many developers to one task in particular, now i would also like to be able to manipulate the other fields i added to the joining table like the ‘estimated_time’, ‘accomplished_time’… etc… what i got on my Simple_form is
`

<%= simple_form_for [@sprint,@task], :html => { :class => 'form-horizontal' } do |f| %>
  <%= f.input :name %>
  <%= f.input :description %>
  <%= f.association :developers, :as => :check_boxes %>

  <div class="form-actions">
    <%= f.button :submit, :class => 'btn-primary' %>
    <%= link_to t('.cancel', :default => t("helpers.links.cancel")),
                project_sprint_path(@sprint.project_id,@sprint), :class => 'btn' %>
  </div>
<% end %>`

This only allows me to select the developers, i want to be able to modify the estimated_time field right there.

Any Suggestions?

  • 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-06-12T22:07:31+00:00Added an answer on June 12, 2026 at 10:07 pm

    I love how simple-form has the association helpers, making it really easy in some cases. Unfortunately, what you want you cannot solve with just simple-form.

    You will have to create assignments for this to work.

    There are two possible approaches.

    For both you will have to add the following to your model:

    class Task
      accepts_nested_attributes_for :assignments
    end
    

    Note that if you are using attr_accesible, you should also add assignments_attributes to it.

    The easy approach

    Suppose you know how many assignments, maximally, a task would have. Suppose 1 for simplicity.

    In your controller, write

    def new
      @task = Task.build
      @task.assignments.build
    end
    

    This will make sure there is one new assignment.

    In your view write:

    = simple_form_for [@sprint,@task], :html => { :class => 'form-horizontal' } do |f| 
      = f.input :name 
      = f.input :description 
    
      = f.simple_fields_for :assignments do |assignment|
        = assignment.association :developer, :as => :select
        = assignment.estimated_time
    
      .form-actions
        = f.button :submit, :class => 'btn-primary'
        = link_to t('.cancel', :default => t("helpers.links.cancel")),
                    project_sprint_path(@sprint.project_id,@sprint), :class => 'btn'
    

    The problem with this approach: what if you want more than 1, 2 or 3?

    Use cocoon

    Cocoon is a gem that allows you to create dynamic nested forms.

    Your view would become:

    = simple_form_for [@sprint,@task], :html => { :class => 'form-horizontal' } do |f| 
      = f.input :name 
      = f.input :description 
    
      = f.simple_fields_for :assignments do |assignment|
        = render `assignment_fields`, :f => assignment
      .links
        = link_to_add_association 'add assignment', f, :assignments
    
      .form-actions
        = f.button :submit, :class => 'btn-primary'
        = link_to t('.cancel', :default => t("helpers.links.cancel")),
                    project_sprint_path(@sprint.project_id,@sprint), :class => 'btn'
    

    And define a partial _assignment_fields.html.haml :

    .nested_fields
      = f.association :developer, :as => :select
      = f.estimated_time
      = link_to_remove_association 'remove assignment', f
    

    Hope this helps.

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

Sidebar

Related Questions

i have two models, Content and Page class Content < ActiveRecord::Base attr_accessible :large_description, :short_description
I have two models, Landscape: class Landscape < ActiveRecord::Base has_many :images, :as => :imageable
I have two models: class Contact(models.Model): name = models.CharField(max_length=255) class Campaign(models.Model): contact = models.ForeignKey(Contact,
I have two models, a Project and an Action: class Project(models.Model): name = models.CharField(Project
I have two models like this: class ClassA(models.Model): ida = models.AutoField(primary_key=True) classb = models.ForeignKey(ClassB)
I have two models based in which one is related to another. class Contacts(BaseModel):
I have two models: class ModelIn{ public string FirstName { get; set; } public
I have two models, Listing and Invitation, associated with has_and_belongs_to_many. I am looking at
I have two Models, Programme and Event, a programme has many events. I need
I have two models: User and Car with the following associations: User has_many Car

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.