-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
In my case, I have a User model that has many Projects and a Project that has many Users, and the relationship between User and Project has attributes such as rate,progress and etc.
Unable to find source-code formatter for language: `ruby. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
class Project include Mongoid::Document field :title, type: String field :description, type: String has_many :related_users, class_name: 'ProjectMembership', inverse_of: :project end class User include Mongoid::Document field :firstname, type: String field :lastname, type: String has_many :related_projects, class_name: 'ProjectMembership', inverse_of: :user end class ProjectMembership include Mongoid::Document field :rate,type: Float belongs_to :user, class_name: 'Project', inverse_of: :related_projects belongs_to :project, class_name: 'User', inverse_of: :related_users end
`
When I try to remove ralated_project from user with this function :
Unable to find source-code formatter for language: `ruby. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
def remove_project(pid)
rel = self.related_projects.where(project_id: pid)[0]
if rel
rel.destroy
end
end
`
It removes ProjectMembership object correctly but user.related_projects still has that ProjectMembership object :
Unable to find source-code formatter for language: `ruby. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
def get_projects
ret = []
self.related_projects.each do |rel|
ret << Project.find(rel.project_id)
end
ret
end
`