`
swachian
  • 浏览: 73366 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Resource-Based Routing

阅读更多

基本增加的内容

Resource-Based Routing依靠restful的风格,定义后增加下面4个helper

 

  client_url       show     update    destroy
  clients_url      index    create
  edit_client_url  edit
  new_client_url   new


  update和destroy通过传入:method来完成
    对于link_to form_tag可直接在client_url后面跟着:method => :delete
    对于form_for来说,会要求跟在一个嵌套hash中 form_for @client, :html => {:method=>:delete}

 

 

单复数route
  两种使用helper的形式
    client_url(@item)        ----参数形式
    clent_url(:id => @item)  ----hash形式

定义自己的action

map.resources :articles, :collection => { :recent => :get }
:collection增加了recent action包括
Method: get
path: /articles/recent
action: recent
helper: recent_articles_url

:member 则给某个实例增加action
map.resources :articles, :member => {:release => :put, :rollback => :put}
Method: put
path: /articles/1/release
action: release
helper: release_article_url

Nested Resources

 有些资源有依赖关系,需要成对出现
  嵌套定音的后果
    map.resources :auctions do |auction|
      auction.resources :bids
    end
      除了autions的4个helper,也为bids定义了auction_bids_url, new_auction_bid_url等等helper。
      nested 使得任何使用bid routes的时候,必须提供auction资源
      对于singular routes需要提供至少两个参数
    
    :name_perfix 使得可以定义helper的前缀
      用nil表示取消前缀
   对于form_for可以采用
     <% form_for([:admin, @post]) do |f| %>

分享到:
评论

相关推荐

    Message matching-based greedy behavior detection in delay tolerant networks

    Delay tolerant networks (DTNs) are resource-constrained networks where messages are relayed in a store-carry-forward fashion. In most routing protocols of DTNs, each node is required to honestly relay...

    软件测试相关论文-英文原文82篇

    Pires2016 - Secure Content-Based Routing Using SGX.pdf Pires2017- A lightweight MapReduce framework for secure processing with SGX.pdf Proof of Luck- an Efficient blockchain consensus protocol.pdf ...

    Networking.for.Big.Data.1482263491

    aware policy-based network management framework that can help you exploit and differentiate user data profiles to achieve better power efficiency and optimized resource management. Table of Contents ...

    OpenStack Networking Guide

    Role-Based Access Control (RBAC) Routed provider networks Service function chaining SR-IOV Subnet pools Service subnets Trunking Deployment examples Prerequisites Mechanism drivers Operations IP ...

    Cisco.Press.CCIE.Self.Study.CCIE.Security.Practice.Labs

    The explosive growth of the Internet economy over the past several years and new IP-based enterprise applications has heightened requirements for continuous availability of mission-critical data....

    Cognitive Radio Networks

    7.3.2 Radio Resource Sensing 216 References 228 8 Medium Access Control 231 8.1 MAC for Cognitive Radios 231 8.2 Multichannel MAC 232 8.2.1 General Description of Multichannel MAC 235 8.2.2 ...

    Sensor Networks and Configuration

    4. Grid computing has evolved as a standards-based approach for coordinated resource sharing. There are several issues and challenges in the design of sensor VIII Preface grids. Chapter 5 has been ...

    restful restful所需要的jar包

    This results in a very flexible yet simple routing with automatic extraction of URI variables into request attributes. * Tunneling service lets browsers issue any HTTP method (PUT, DELETE, MOVE, etc...

    Altium Designer Documentation.rar

    Altium Designer 全部文档打包,268个pdf格式文件, AD10-Next_Generation_Component_Management.pdf AltiumVaults - Opening the Vault doors.pdf ...CR0124 FPGA Arithmetic Function Resource Usage.pdf

    一本android的好书beginning android 2 和 源码

    Intent Routing Stating Your Intent(ions) Narrow Receivers The Pause Caveat ■Chapter 18: Launching Activities and Subactivities Peers and Subs Start ’Em Up Make an Intent Make the Call Tabbed ...

    Web Caching and Replication

    Uniform Resource Locators Section 4.2. The Domain Name System Section 4.3. The HyperText Transfer Protocol Section 4.4. The HTTP Message Exchange Section 4.5. Hyperlinks and Embedded Objects ...

    Performance analysis of an integrated scheme in optical burst switching high-speed networks

    A new integrated scheme based on resource-reservation and adaptive network flow routing to alleviate contention in optical burst switching networks is proposed. The objective of the proposed scheme is...

    SimIt-ARM-3.0 ARM指令模拟器

    SimIt-ARM-3.0 给予命令行ARM指令模拟器,短小精悍,是研究ARM处理器的好工具,该模拟器既可以运行用户级别的ELF程序,又可以模拟运行Linux操作系统;提供了简单易用的调试命令,可以逐条跟踪指令的执行。...

    Game Theory for Wireless Engineers

    based on perceived or measured results. In the early to mid-1990’s, game theory was applied to networking problems including flow control, congestion control, routing and pricing of Internet services...

    pro_apache_third_edition..pdf

    Netmasks and Routing......................................................................................21 Web Services: Well-Known Ports................................................................

    新鲜出炉的PCI-E协议3.0

    2.2.4. Routing and Addressing Rules.............................................................................. 60 2.2.5. First/Last DW Byte Enables Rules..............................................

    LTE from A-Z 培训教材 (part2 of 3)

    著名培训机构的LTE培训教材。 深入浅出,从基本概念到深入描述。是一份比较全面的教材。全文367页。有料有内容。是一份难得的教材。 文件比较大,所以拆成3部分。这是part2 ...Principles and Motivation of LTE.........

    ZendFramework中文文档

    2.1.1. 关于资源(Resource) 2.1.2. 关于角色(Role) 2.1.3. 创建访问控制列表(ACL) 2.1.4. 注册角色(Role) 2.1.5. 定义访问控制 2.1.6. 查询 ACL 2.2. 精细的访问控制 2.2.1. 精细的访问控制 2.2.2. 除去访问...

    LTE from A to Z (part1 of 3)

    著名培训机构的LTE培训教材。 深入浅出,从基本概念到深入描述。是一份比较全面的教材。全文367页。有料有内容。是一份难得的教材。 文件比较大,所以拆成3部分。这是part1 ...Principles and Motivation of LTE.........

Global site tag (gtag.js) - Google Analytics