`

Generate a list of Rails controllers and methods

阅读更多
列出项目中的controler和他对应的actions:
@controller_actions = ActionController::Routing::Routes.routes.inject({}) do |controller_actions, route|
      (controller_actions[route.requirements[:controller]] ||= []) << route.requirements[:action]
      controller_actions
end

来源:http://snippets.dzone.com/posts/show/4792
分享到:
评论

相关推荐

    RJS Templates for Rails

    RJS templates are an exciting and powerful new type of template added to Rails 1.1. Unlike conventional Rails templates that generate HTML or XML, RJS templates generate JavaScript code that is ...

    Rails3 device and cancan

    标题《Rails3 device and cancan》与描述《ROR ruby on rails device plugin教程》指出本文是关于如何在Rails 3.2应用程序中整合Devise认证插件和Cancan授权插件的教程。Devise是一个流行的Ruby on Rails的认证解决...

    Ruby on Rails Tutorial Learn Rails by Example 的源代码

    8. **生成器和迁移**:Rails提供了一些命令行工具,如`rails generate`和`rails db:migrate`,用于快速生成模型、控制器、迁移等,并执行数据库迁移。 9. **测试**:Rails鼓励TDD(测试驱动开发),`spec`目录包含...

    MyBatis-Generate

    It will generate code for all versions of MyBatis, and versions of iBATIS after version 2.2.0. It will introspect a database table (or many tables) and will generate artifacts that can be used to ...

    create todo list ruby on rails

    ### 创建To-Do List应用:使用Ruby on Rails的详尽指南 #### 一、引言与背景 在当今快速发展的互联网行业中,开发高效且功能强大的Web应用变得越来越重要。Ruby on Rails(RoR)作为一款优秀的Web应用开发框架,...

    Handbook of Research on Soft Computing and Nature-Inspired Algorithms

    Featuring comprehensive coverage on a range of topics and perspectives such as swarm intelligence, speech recognition, and electromagnetic problem solving, this publication is ideally designed for ...

    Handbook of Blockchain,Digital Finance, and Inclusion, Volumes 1 and 2

    Financial inclusion and impact investment are not viewed as main stream activities. Recent exodus of senior bankers and financial ...models and may help to generate sustainable new revenue streams.

    rails向导打包

    7. **Rails 命令行工具和 Rake 任务**: Rails 提供了一系列命令行工具,如 `rails server`、`rails generate` 和 `rails dbconsole`,帮助开发者快速启动、生成代码和操作数据库。Rake 是一个构建工具,用于执行任务...

    Ruby on Rails入门例子

    2. 创建资源:使用`rails generate controller Posts`生成控制器,再用`rails generate scaffold Post title:string content:text`生成模型和相关的控制器、视图及路由。 3. 迁移数据库:编写迁移文件,更新数据库表...

    中文版rails教程

    1. **生成资源(Generating Resources)**:使用`rails generate`命令可以快速创建模型、控制器、视图等文件,如`rails generate scaffold Post title:string content:text`会生成一个名为Post的资源,包含相关的...

    MVCScaffolding入门资源

    MVC Scaffolding, maintained by Steve Sanderson, provides a way to quickly generate code for views and controllers in your ASP.NET MVC application. It has support for scaffolding the following: Views ...

    Ruby+for+Rails

    `rails generate migration AddColumnToBooks column:type`会生成一个新的迁移文件,然后通过`rails db:migrate`执行迁移,更新数据库。 7. **路由(Routing)** Rails的路由系统将URL映射到控制器的动作上,定义...

    Ruby on Rails实例开发

    接着,使用Rails的生成器创建控制器、模型和视图,如`rails generate controller`或`rails generate model`。然后,配置数据库连接,编写数据库迁移(migrations)以定义数据表结构,执行`rake db:migrate`来应用...

    rails操作.docx

    通过`rails generate`命令,可以自动生成控制器、模型、视图等相关文件,例如创建一个名为`autoweb`的应用,只需执行`rails generate controller Autoweb`,Rails会自动创建相关文件,开发者只需要填充具体业务逻辑...

    Rails 101S

    - 示例:通过`rails generate scaffold Topic title:string description:text`创建一个Topic模型及其关联的CRUD操作。 - **整合Bootstrap与版型设置**:介绍如何将Bootstrap框架集成到Rails应用中,并设置基础版型...

    Rails进行敏捷Web开发(所有版本的源码rails3.0-4.0)

    此外,`rails generate scaffold`命令也变得更加灵活,可以自定义模板。 4. Rails 4.0: Rails 4带来了大量的改变和优化。最显著的是加入了Strong Parameters,提高了安全性,避免了Mass Assignment漏洞。另外,它...

    centOS Rails3环境搭建

    rails generate scaffold person name:string bio:text birthday:date ``` - **模型创建与删除**: ```bash rails generate model article rails destroy model article ``` - **控制器创建**: ```bash ...

    Ruby on Rails入门经典代码

    Ruby on Rails,简称Rails,是基于Ruby语言的一个开源Web应用程序框架,它遵循MVC(Model-View-Controller)架构模式,旨在使Web开发过程更加高效、简洁。本压缩包中的"Ruby on Rails入门经典代码"提供了新手学习...

Global site tag (gtag.js) - Google Analytics