小编Joh*_*uff的帖子

Rails中默认RESTFUL路由的覆盖方法

给出下面的一行代码 routes.rb

map.resources :users
Run Code Online (Sandbox Code Playgroud)

生成的路由可能是这样的:

      users GET    /users(.:format)           {:controller=>"users", :action=>"index"}
            POST   /users(.:format)           {:controller=>"users", :action=>"create"}
   new_user GET    /users/new(.:format)       {:controller=>"users", :action=>"new"}
  edit_user GET    /users/:id/edit(.:format)  {:controller=>"users", :action=>"edit"}
       user GET    /users/:id(.:format)       {:controller=>"users", :action=>"show"}
            PUT    /users/:id(.:format)       {:controller=>"users", :action=>"update"}
            DELETE /users/:id(.:format)       {:controller=>"users", :action=>"destroy"}
Run Code Online (Sandbox Code Playgroud)

有没有办法将POST /users映射的默认HTTP方法更改{:controller=>"users", :action=>"create"}为用于PUT替代的HTTP方法?

rake routes 然后生成这样的东西:

      users GET    /users(.:format)           {:controller=>"users", :action=>"index"}
            PUT    /users(.:format)           {:controller=>"users", :action=>"create"}
   new_user GET    /users/new(.:format)       {:controller=>"users", :action=>"new"}
  edit_user GET    /users/:id/edit(.:format)  {:controller=>"users", :action=>"edit"}
       user GET    /users/:id(.:format)       {:controller=>"users", :action=>"show"}
            PUT    /users/:id(.:format)       {:controller=>"users", :action=>"update"}
            DELETE /users/:id(.:format)       {:controller=>"users", …
Run Code Online (Sandbox Code Playgroud)

rest resources routing ruby-on-rails

5
推荐指数
1
解决办法
3080
查看次数

正则表达式匹配分数而不是日期

我正在尝试提出一个正则表达式,它将匹配一个字符串中的分数(1/2)而不是日期(5/5/2005).任何帮助都会很棒,所有我能想到的是(\ d +)/(\ d +),它们在两个字符串中找到匹配项.在此先感谢您的帮助.

regex

4
推荐指数
2
解决办法
2161
查看次数

在使用jquery验证插件时重置表单

我有一个简单的表单,如下所示,我已将jQuery验证插件添加到(http://docs.jquery.com/Plugins/Validation).我在一个模态弹出窗口中有这个表单,所以如果有错误并且用户在再次打开它时关闭窗口,表单仍然有错误.在我的弹出关闭回调中,我尝试调用resetForm(),但它说该方法不存在.

表单HTML:

 <form class="validations" id="commentForm" method="get" action="">
   <p>
     <label for="name">Name</label>
     <em>*</em><input id="name" name="name" size="25" class="required" minlength="2" />
   </p>
   <p>
     <label for="email">E-Mail</label>
     <em>*</em><input id="email" name="email" size="25"  class="required email" />
   </p>
 </form>
Run Code Online (Sandbox Code Playgroud)

弹出关闭回调:

function(){
  $(this).find('form.validations').resetForm();
}
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助.

javascript validation jquery reset jquery-validate

4
推荐指数
1
解决办法
5971
查看次数

表格td上的CSS背景颜色在Internet Explorer 6中显示不正确

我有一些非常简单的HTML和CSS在Internet Explorer 6中不起作用.

<!DOCTYPE HTML>
<html>
    <head>
        <style>        
            table td.one.read {background-color:#FFD700;}
            table td.two.read {background-color:#0000ff;}
            table td.three.read {background-color:#ff8c00;}
        </style>
    </head>

    <body>
        <table>
            <tr class="head">
                <td></td>
                <td class='one read'>one</td>
                <td class='two read'>two</td>
                <td class='three read'>three</td>
            </tr>

            <tr>
                <td>Legend</td>
                <td class='one read'>1</td>
                <td class='two read'>2</td>
                <td class='three read'>3</td>
            </tr>
        </table>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

一个简单的表,每列具有不同的背景颜色.我删除了一堆其他的CSS/HTML以保持简单.问题是所有列在Internet Explorer 6中显示为相同的橙色,在Firefox中工作正常.

我怎样才能使它工作?

html css html-table background-color internet-explorer-6

1
推荐指数
1
解决办法
8734
查看次数