{"id":13879288,"url":"https://github.com/jasl/cybros_core","last_synced_at":"2025-03-16T16:30:39.193Z","repository":{"id":34275511,"uuid":"174189514","full_name":"jasl/cybros_core","owner":"jasl","description":"A demo app to show some Rails app configurations","archived":false,"fork":false,"pushed_at":"2023-03-08T20:16:16.000Z","size":2529,"stargazers_count":122,"open_issues_count":13,"forks_count":26,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-12T03:53:08.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jasl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-06T17:25:18.000Z","updated_at":"2022-07-03T06:39:05.000Z","dependencies_parsed_at":"2023-02-11T22:01:15.330Z","dependency_job_id":null,"html_url":"https://github.com/jasl/cybros_core","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasl%2Fcybros_core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasl%2Fcybros_core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasl%2Fcybros_core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasl%2Fcybros_core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jasl","download_url":"https://codeload.github.com/jasl/cybros_core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221665766,"owners_count":16860310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:02:16.295Z","updated_at":"2024-10-27T10:53:51.537Z","avatar_url":"https://github.com/jasl.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"Cybros Core\n====\n\n[![CircleCI](https://circleci.com/gh/jasl/cybros_core.svg?style=svg)](https://circleci.com/gh/jasl/cybros_core)\n\nThis is a barebone Rails 6.0 app to show some basic configurations.\n\nI'm used to maintaining a barebone app that helps me build new project quickly,\nand this is extracted from my side project initially for sharing my ideas to friends,\nbut if this is valuable to you, use it freely.\n\n## Goal\n\nI hope this could be a template for new apps, it should be production-ready,\nso I'll keep polishing the codebase, follow best practice, keep dependencies up to date.\n\nI don't wanna add too much features especially business-specific,\nbut I'd like to perfection User system (based on Devise) because most apps need this,\nand keep improving UI/UX relates works.\n\nBTW: I'm really hoping someone could extract GitLab's user system.\n\nI list some helps wanted, see below.\n\n## Features\n\n### Classic front-end\n\nPersonally, I'm not skilled at front-end and I still prefer classic Rails server-side rendering,\nand partially introduce React or Vue for complex pages.\n\nA good example is Gitlab, I also cheat some useful helpers to this app.\n\n#### Webpacker 5 without Sprockets\n\nWebpacker can do all the jobs that Sprockets does,\nand has full support of front-end community,\nSo I remove Sprockets and tune Webpacker allows Assets Pipeline experience.\n\nI do these:\n\n- Remove gems related to Sprockets\n- Search and remove `assets` related configs\n- `resolved_paths: ['app/assets']` in `config/webpacker.yml`\n- `app/javascript/packs/application.js` require all static assets (images, webfonts, etc.)\n\n#### CoreUI with Bootstrap, FontAwesome\n\nSee `app/assets/stylesheets/application.scss`\n\n### Application configuration\n\n#### A hack about Rails Credentials\n\nRails Credentials is a useful feature to store security-sensitive configs.\n\nBut we can't bundle `master.key`, and `credentials.yml.enc` isn't readable,\nso it's difficult to redistribute the app,\nI gave a [PR to Rails](https://github.com/rails/rails/pull/34777) but no respond,\nI consistantly think it's useful so I integrate it as a hack, see `bin/rails`.\n\nSo you can copy `config/credentials.yml.example` as `config/credentials.yml`,\nedit it, then run `rails credentials:encrypt` that will generate `config/credentials.yml.enc` and `config/master.key` for you.\n\n#### A hack about ActionMailer configuration\n\nUnlike `database.yml`, ActionMailer's config separates in many files,\nI do a hack that you can config ActionMailer in one place.\n\nSee `config/mailer.yml`\n\nCodes in `config/application.rb`\n\n### Implemented a full-feature layouts \u0026 views\n\nI don't have art skill but ... at least it works!\n\n#### Overrides Form Helpers to enhance them to support Bootstrap form validation style\n\nThe technique is in \u003chttps://guides.rubyonrails.org/engines.html#implementing-decorator-pattern-using-class-class-eval\u003e\n\nSee `app/overrides/action_view/helpers/form_builder_override.rb`\n\nIn addition, see `config/application.rb` for how to require overrides.\n\n#### Don't render ActionView's default error field wrapper\n\nThat will break many CSS frameworks.\n\nSee `config/initializers/action_view.rb`\n\n#### Default value for model fields\n\nSee `app/models/concerns/acts_as_default_value.rb`\n\nDefault value of column can only be a static value,\nActive Record's `attribute` DSL can set default for field but doesn't have entity context,\nUsing hooks (such as `after_initilize`) to set default values has edge cases,\nyou can use `default_value_for` to set default value.\n\nHere's a complex example:\n\n```ruby\ndefault_value_for :role_id,\n                    -\u003e (member) {\n                      if member.has_attribute?(:tenant_id) || member.tenant\n                        member\u0026.tenant\u0026.member_role\u0026.id\n                      end\n                    }, allow_nil: false\n```\n\n#### I18n for `enum`\n\nSee `app/models/concerns/enum_attribute_localizable.rb`\n\nRails doesn't have best practice for `enum` I18n,\nI integrate my personal practice.\n\nFor example, I have a model `Post` with `status` column for `enum`\n\n```ruby\nclass Post \u003c ApplicationRecord\n  enum status: %i[draft published archived]\nend\n```\n\nThe locale `post.en.yml` looks like\n\n```yaml\nen:\n  activerecord:\n    models:\n      post: Post\n    attributes:\n      post:\n        status: Status\n        statuses:\n          draft: Draft\n          published: Published\n          archived: Archived\n```\n\nTo render human readable post's status, you can do like this:\n\n```ruby\nPost.human_enum_value(:status, @post)\n```\n\n### Undocumented yet\n\nTODO:\n\n## Run the app\n\n- Clone it\n- `bundle`\n- `yarn`\n- `cp config/database.yml.example config/database.yml`\n- `cp config/credentials.yml.example config/credentials.yml` \u0026 `rails credentials:encrypt`\n- `cp config/mailer.yml.example config/mailer.yml`\n- `rails db:migrate`\n- `rails s`\n\n### Receive Devise confirmation mail\n\nIn development, I use `mailcatcher` to receive mails,\nrun `gem install mailcatcher` to install it.\n\nOpen a new terminal, run `mailcatcher`, then follow the instructions\n\n### Set user as admin\n\n- `cp config/settings.yml config/settings.local.yml`\n- Put your email into `admin.emails`\n- In user menu (right-top of pages), you should see `Administration`\n\n## Troubleshooting\n\nMake sure run `gem update --system` to use latest Rubygem\n\n## Help wanted\n\n- UI/UX design \u0026 SCSS \u0026 HTML improvement\n- Layout for mails\n- Coding style \u0026 structural improvement\n- Try support uploading user avatar using ActiveStorage\n- Find bugs\n- Docker for deployment, including stages to compiling assets \u0026 copy `yml`s, easy to migrate to k8s\n\n## Screenshots\n\n![Sign in page](_screenshots/sign_in_page.png)\n![Admin user page](_screenshots/admin_user_page.png)\n\n## License\n\n[MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasl%2Fcybros_core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasl%2Fcybros_core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasl%2Fcybros_core/lists"}