hemmpa

Joined

200 Experience
1 Lesson Completed
0 Questions Solved

Activity

Hi,

I have been having having a challenging problem as my rails skill is still not great.

I am using a cocoons gem to generate nested forms. I have three models Employee , Competence and Skill where I have just a basic associations.
in Employee model

 has_many :competences

and in Competence model

belongs_to :employee

So I am generating competences nested forms in employee form. And in competences form I have a skill attribute where I used a select box. This select box is populated with list of skills from the Skill model as below

      <%= f.collection_select :skill_id, Skill.all, :id, :skill_name, options={include_blank: true}, html_options={class: 'selectize', required: true} %>

What I wanted to achieve is that, in the skills select box I get all skills from the skills model regardless of that skill is already been selected in another competences form. So I wanted the select options are only those new skills which are not already selected in another nested competences form.

This is to avoid selection the same skill in the nested form more than once as it is difficult to see as the nested forms list grows.

Any suggestion is appricaited!

Posted in how do I exclude one field from being updated?

I wanted to achieve that a ceratin field can not be overwritten by an update process. instead to store the new input for that field in a new column.