Forum: Ruby on Rails build from form has_many through

3cf4fd3b2754a837689894db479c154c?d=identicon&s=25 Adel M. (adel_m)
on 2017-01-08 03:48
Attachment: redmine.jpg (100 KB)
hello.
i would like to add to an existing project some future.
i work with redmine, i would like to create for each project a
check-list.
check-lists are managed by admin, so he can create , update and delete
tasks.
A check-list look like:
Commercial:
 task-1
 task-2
 task-n
developper:
 task-..
 ....

its just an example, admin can create other tasks and tasks-categroie.
this part is ok:
i have a model named ncchecklist:

class Nccheklist < ActiveRecord::Base
  belongs_to :parent, class_name: "Nccheklist"
  has_many :children, class_name: "Nccheklist", foreign_key: :parent_id

  def self.roots
    return Nccheklist.where(parent_id: nil)
  end

  def siblings
    if parent
      parent.children.where.not(id: self.id)
    else
      Nccheklist.top_level.where.not(id: self.id)
    end
  end

  def has_parent?
    parent.present?
  end

  def is_leaf?
    self.children.empty?
  end

  def is_root?
    parent.nil?
  end
  def has_children?
    children.exists?
  end

end


now i would like to add a form in the project view with tasks and radio
button true/false, and user check it if he and the task.

each project have all tasks but of course with different value.
the goal is that each user ( employee ) say if yes or no he has end task
attached to his position.


hope some-one can help me and sorry for my poor english.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.