Skip to content
Snippets Groups Projects

Remove models/roles and return to fat models

Merged gitlab-qa-bot requested to merge remove_roles into master

Created by: dzaporozhets

After half of year with models roles I'd like to remove them from system Reasons below:

  • its difficult to define where method goes (role or model)
  • roles are closely connected to model fields so changing model requires changing some or roles
  • its easily to duplicate method already defined in another role
  • testing roles requires a model anyway
  • it is complicated to search for method having few roles

So I suggest to return to fat models + libs

I saved Vote, IssueCommonality, StaticModel as libs. Also I am going to extract Repository from project in future in separate class in libraries

Feedback from core team is appreciated

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Created by: riyad

    :thumbsup: sounds reasonable

    By Administrator on 2013-01-02T22:52:35 (imported from GitLab project)

    By Administrator on 2013-01-02T22:52:35 (imported from GitLab)

  • Created by: riyad

    But I'd say the roles that survive should go into the app/models directory. It's generally clear from the name, that some files are not AR models. "GitHost" is basically a one-liner and could be merged into Project (why is it called git_host when all the docs say it's about Gitolite? maybe it should be called gitolite or gitolite_bridge). Voteable can also be merged into IssueCommonality.

    By Administrator on 2013-01-02T23:02:39 (imported from GitLab project)

    By Administrator on 2013-01-02T23:02:39 (imported from GitLab)

  • Created by: jirutka

    @randx Well, I understand your reasons, but on the other hand, 786 lines long model…?! This is really too much, isn’t it?

    By Administrator on 2013-01-03T00:47:32 (imported from GitLab project)

    By Administrator on 2013-01-03T00:47:32 (imported from GitLab)

  • Created by: SaitoWu

    Fat models has its problem, cause its toooo fat.

    I like the idea from @dhh, also it will be default on Rails 4.

    app/models/concerns and app/controllers/concerns

    Also DHH wrote a blog for it: http://37signals.com/svn/posts/3372-put-chubby-models-on-a-diet-with-concerns

    Github commit: https://github.com/rails/rails/commit/f6bbc3f582bfc16da3acc152c702b04102fcab81

    On the other hand , a test shows that 'DCI' is so slow.

    https://gist.github.com/4321750

    By Administrator on 2013-01-03T03:32:58 (imported from GitLab project)

    By Administrator on 2013-01-03T03:32:58 (imported from GitLab)

  • Created by: dzaporozhets

    Thank you for suggestions.

    1. Will remove githost
    2. Merge vote into issue commonality
    3. Move issuecommonality into models/concerns
    4. Extract repository in separate class

    By Administrator on 2013-01-03T06:13:34 (imported from GitLab project)

    By Administrator on 2013-01-03T06:13:34 (imported from GitLab)

Please register or sign in to reply
Loading