{"id":13672597,"url":"https://github.com/xaqi/mini-rails","last_synced_at":"2025-04-27T22:32:25.810Z","repository":{"id":217579729,"uuid":"77208745","full_name":"xaqi/mini-rails","owner":"xaqi","description":" 仅有600行代码的精简版Rails，可作为学习Rails源码的向导。","archived":false,"fork":false,"pushed_at":"2017-04-12T16:39:13.000Z","size":14,"stargazers_count":55,"open_issues_count":0,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-11T10:42:36.193Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xaqi.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-23T07:57:30.000Z","updated_at":"2024-07-18T07:30:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"317fe87d-8f70-400e-8749-a0709e272606","html_url":"https://github.com/xaqi/mini-rails","commit_stats":null,"previous_names":["xaqi/mini-rails"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaqi%2Fmini-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaqi%2Fmini-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaqi%2Fmini-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xaqi%2Fmini-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xaqi","download_url":"https://codeload.github.com/xaqi/mini-rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251219601,"owners_count":21554444,"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-02T09:01:40.959Z","updated_at":"2025-04-27T22:32:25.805Z","avatar_url":"https://github.com/xaqi.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"mini-rails  \r\n=====================\r\nRubyChina讨论贴：\u003ca href=\"https://ruby-china.org/topics/32764\" target=\"_blank\"\u003ehttps://ruby-china.org/topics/32764\u003c/a\u003e\r\n\r\n## What is mini-rails?\r\n\r\n本想学习一下Rails源码，看看有什么magic；\u003cbr /\u003e\r\n但源码文件太多，核心代码都淹没在大量细节实现中，全部看完不现实，走马观花又很难领会精髓； \u003cbr /\u003e\r\n纸上得来终觉浅，眼过千遍，不如手过一遍，干脆重新造个轮子；\u003cbr /\u003e\r\n于是就有了mini-rails，参照Rails源码，省略细节，实现了一个self-host mvc框架；\u003cbr /\u003e\r\n再也不用对着庞大的Rails望洋兴叹了，600行代码为您还原一个真实的Rails；\u003cbr /\u003e\r\n\r\nmini-rails实现了从socket到controller的层层封装，并注释了Rails源码中相应模块的位置，可作为学习Rails源码的目录或大纲；\u003cbr /\u003e\r\n```\r\nSocket -\u003e WEBrick GenericServer -\u003e WEBrick HTTPServer -\u003e WEBrick HTTPServlet\r\n-\u003e Rack WEBrick -\u003e Rack Handler -\u003e Rack Server\r\n-\u003e Rails Server -\u003e Engine -\u003e Application -\u003e Middleware -\u003e ActionDispatch::Executor\r\n-\u003e MiddlewareStack -\u003e Routing\r\n-\u003e Journey Router -\u003e AbstractController -\u003e Metal -\u003e ActionController::Base\r\n```\r\n\r\n## How to run it?\r\n```ruby\r\n#运行test.rb，打开浏览器：\r\nhttp://localhost:8081/Home/index        =\u003e \"hello from Home Index.\"\r\nhttp://localhost:8081/User/about        =\u003e \"hello from User About.\"\r\nhttp://localhost:8081/unkown_url        =\u003e \"404\"\r\n```\r\n\r\n## How to define a web page?\r\n```ruby\r\nrequire_relative 'mini-rails'\r\n\r\n#define your controllers and actions\r\nclass UserController \u003c ActionController::Base\r\n    def about\r\n        ['200',[],[\"hello from User About.\"]]\r\n    end\r\nend\r\n\r\nstart_server\r\n\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxaqi%2Fmini-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxaqi%2Fmini-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxaqi%2Fmini-rails/lists"}