- 浏览: 2072559 次
- 性别:
- 来自: NYC
文章分类
- 全部博客 (628)
- Linux (53)
- RubyOnRails (294)
- HTML (8)
- 手册指南 (5)
- Mysql (14)
- PHP (3)
- Rails 汇总 (13)
- 读书 (22)
- plugin 插件介绍与应用 (12)
- Flex (2)
- Ruby技巧 (7)
- Gem包介绍 (1)
- javascript Jquery ext prototype (21)
- IT生活 (6)
- 小工具 (4)
- PHP 部署 drupal (1)
- javascript Jquery sort plugin 插件 (2)
- iphone siri ios (1)
- Ruby On Rails (106)
- 编程概念 (1)
- Unit Test (4)
- Ruby 1.9 (24)
- rake (1)
- Postgresql (6)
- ruby (5)
- respond_to? (1)
- method_missing (1)
- git (8)
- Rspec (1)
- ios (1)
- jquery (1)
- Sinatra (1)
最新评论
-
dadadada2x:
user模型里加上 protected def email ...
流行的权限管理 gem devise的定制 -
Sev7en_jun:
shrekting 写道var pattern = /^(0| ...
强悍的ip格式 正则表达式验证 -
jiasanshou:
好文章!!!
RPM包rpmbuild SPEC文件深度说明 -
寻得乐中乐:
link_to其实就是个a标签,使用css控制,添加一个参数: ...
Rails在link_to中加参数 -
aiafei0001:
完全看不懂,不知所然.能表达清楚一点?
"$ is not defined" 的问题怎么办
今天费了一些时间啊一个很久之前遇到过的问题又忘了
Rails 3
写了个路由
rake routes可以知道
于是,就写了个button_to
发现诡异现象,点击就会提示没有路由,地址栏回车就能显示。
我就记着很久之前遇到过这个问题,可是就是想不起来怎么回事。
后来看后台信息和地址栏,发现问题
后台
Started POST "/report/index?method=get" for 192.168.1.130 at 2011-05-19 14:04:41 -0400
ActionController::RoutingError (No route matches "/report/index"):
仔细看看API
发现少了个大括号
button_to(name, options = {}, html_options = {})
Generates a form containing a single button that submits to the URL created by the set of options. This is the safest method to ensure links that cause changes to your data are not triggered by search bots or accelerators. If the HTML button does not work with your layout, you can also consider using the link_to method with the :method modifier as described in the link_to documentation.
The generated form element has a class name of button_to to allow styling of the form itself and its children. You can control the form submission and input element behavior using html_options. This method accepts the :method and :confirm modifiers described in the link_to documentation. If no :method modifier is given, it will default to performing a POST operation. You can also disable the button by passing :disabled => true in html_options. If you are using RESTful routes, you can pass the :method to change the HTTP verb used to submit the form.
Options
The options hash accepts the same options as url_for.
There are a few special html_options:
:method - Symbol of HTTP verb. Supported verbs are :post, :get, :delete and :put. By default it will be :post.
:disabled - If set to true, it will generate a disabled button.
:confirm - This will use the unobtrusive JavaScript driver to prompt with the question specified. If the user accepts, the link is processed normally, otherwise no action is taken.
:remote - If set to true, will allow the Unobtrusive JavaScript drivers to control the submit behaviour. By default this behaviour is an ajax submit.
Rails 3
写了个路由
get "report/index" get "report/show"
rake routes可以知道
report_index GET /report/index(.:format) {:controller=>"report", :action=>"index"} report_show GET /report/show(.:format) {:controller=>"report", :action=>"show"}
于是,就写了个button_to
%h1 Report#show = button_to('click', :action => 'index',:method=>:get)
发现诡异现象,点击就会提示没有路由,地址栏回车就能显示。
我就记着很久之前遇到过这个问题,可是就是想不起来怎么回事。
后来看后台信息和地址栏,发现问题
引用
http://127.0.0.1/report/show?method=get
后台
引用
Started POST "/report/index?method=get" for 192.168.1.130 at 2011-05-19 14:04:41 -0400
ActionController::RoutingError (No route matches "/report/index"):
仔细看看API
<%= button_to "New", :action => "new" %> # => "<form method="post" action="/controller/new" class="button_to"> # <div><input value="New" type="submit" /></div> # </form>" <%= button_to "Delete Image", { :action => "delete", :id => @image.id }, :confirm => "Are you sure?", :method => :delete %> # => "<form method="post" action="/images/delete/1" class="button_to"> # <div> # <input type="hidden" name="_method" value="delete" /> # <input data-confirm='Are you sure?' value="Delete" type="submit" /> # </div> # </form>"
发现少了个大括号
引用
button_to(name, options = {}, html_options = {})
Generates a form containing a single button that submits to the URL created by the set of options. This is the safest method to ensure links that cause changes to your data are not triggered by search bots or accelerators. If the HTML button does not work with your layout, you can also consider using the link_to method with the :method modifier as described in the link_to documentation.
The generated form element has a class name of button_to to allow styling of the form itself and its children. You can control the form submission and input element behavior using html_options. This method accepts the :method and :confirm modifiers described in the link_to documentation. If no :method modifier is given, it will default to performing a POST operation. You can also disable the button by passing :disabled => true in html_options. If you are using RESTful routes, you can pass the :method to change the HTTP verb used to submit the form.
Options
The options hash accepts the same options as url_for.
There are a few special html_options:
:method - Symbol of HTTP verb. Supported verbs are :post, :get, :delete and :put. By default it will be :post.
:disabled - If set to true, it will generate a disabled button.
:confirm - This will use the unobtrusive JavaScript driver to prompt with the question specified. If the user accepts, the link is processed normally, otherwise no action is taken.
:remote - If set to true, will allow the Unobtrusive JavaScript drivers to control the submit behaviour. By default this behaviour is an ajax submit.
发表评论
-
Destroying a Postgres DB on Heroku
2013-04-24 10:58 928heroku pg:reset DATABASE -
VIM ctags setup ack
2012-04-17 22:13 3255reference ctags --extra=+f --e ... -
alias_method_chain方法在3.1以后的替代使用方式
2012-02-04 02:14 3288alias_method_chain() 是rails里的一个 ... -
一些快速解决的问题
2012-01-19 12:35 1470问题如下: 引用Could not open library ... -
API service 安全问题
2011-12-04 08:47 1380这是一个长期关注的课题 rest api Service的 ... -
Module方法调用好不好
2011-11-20 01:58 1344以前说,用module给class加singleton方法,和 ... -
一个ajax和rails交互的例子
2011-11-19 01:53 1903首先,这里用了一个,query信息解析的包,如下 https: ... -
Rails 返回hash给javascript
2011-11-19 01:43 2272这是一个特别的,不太正统的需求, 因为,大部分时候,ajax的 ... -
关于Rubymine
2011-11-18 23:21 2263开个帖子收集有关使用上的问题 前一段时间,看到半价就买了。想 ... -
ruby中和javascript中,动态方法的创建
2011-11-18 21:01 1234class Klass def hello(*args) ... -
textmate快捷键 汇总
2011-11-16 07:20 8138TextMate 列编辑模式 按住 Alt 键,用鼠标选择要 ... -
Ruby面试系列六,面试继续面试
2011-11-15 05:55 2018刚才受到打击了,充分报漏了自己基础不扎实,不肯向虎炮等兄弟学习 ... -
说说sharding
2011-11-13 00:53 1481这个东西一面试就有人 ... -
rails面试碎碎念
2011-11-12 23:51 1939面试继续面试 又有问ru ... -
最通常的git push reject 和non-fast forward是因为
2011-11-12 23:29 17209git push To git@github.com:use ... -
Rails 自身的many to many关系 self has_many
2011-11-12 01:43 2732简单点的 #注意外键在person上people: id ... -
Rails 3下的 in place editor edit in place
2011-11-12 01:20 945第一个版本 http://code.google.com/p ... -
Heroku 的诡异问题集合
2011-11-11 07:22 1692开个Post记录,在用heroku过程中的一些诡异问题和要注意 ... -
SCSS 和 SASS 和 HAML 和CoffeeScript
2011-11-07 07:52 12952Asset Pipeline 提供了内建 ... -
Invalid gemspec because of the date format in specification
2011-11-07 02:14 2115又是这个date format的错误。 上次出错忘了,记录下 ...
相关推荐
2. `React-Router`:React的路由库,实现SPA(单页应用)中的页面切换,与RESTful路由约定相配合。 3. `axios`或`fetch`:用于发送HTTP请求,从服务器获取或提交数据。 **文件结构分析** 在`blogAppRedux-master`...
3. 按钮(Button)和图标(Icon):丰富的样式和图标供选择,满足不同设计需求。 4. 通知提示(Message、Notification):用于全局消息提示。 5. 导航(Navigation):包含菜单(Menu)、面包屑(Breadcrumb)、步骤...
React Admin Oliver使用Material-UI构建了直观且一致的用户界面,源码中可以看到各种组件如Button、Table、Card等的使用,以及如何通过自定义主题来改变界面风格。 4. RESTful API交互:React Admin Oliver通过...
以上知识点构成了一套完整的前端开发流程,通过Vue CLI搭建项目结构,Vue.js负责页面逻辑,ElementUI美化界面,axios处理数据通信,再配合Vue Router和Vuex管理应用状态,共同打造出这个高效且功能完备的单页点餐...
此外,可能会运用到路由管理库如React Router,实现页面间的跳转和导航。 文件名称“kwan02251353”看起来可能是项目文件夹或者主入口文件的名字,这通常包含了项目的启动脚本或者配置信息。在React项目中,这可能...
它采用MVVM模式,允许开发者声明式地渲染动态数据到视图,同时提供了丰富的插件和工具链支持,如Vuex(状态管理)、Vue Router(路由管理)等。 2. **Element UI**:Element UI包含了各种常用的UI组件,如el-table...
3. 路由管理:Vue Router是Vue.js官方的路由库,负责页面间的导航和状态管理,使得单页应用(SPA)的构建更加顺畅。 四、ElementUI组件库 1. UI设计:ElementUI是一套基于Vue.js的组件库,提供了一系列符合...
5. **RESTful API通信** - 为了存储和检索Todo数据,项目可能会与后端服务器进行通信。这通常通过发送HTTP请求实现,遵循RESTful原则。可能使用`fetch` API或`axios`库来处理这些请求。 6. **JSON格式** - 数据交换...
此外,Redux 和 MobX 等库可以帮助管理更复杂的跨组件状态,而 React Router 可用于实现应用程序的路由功能,使得单页应用可以处理多个视图或页面。 在实际开发中,React 应用通常会与后端服务通过 RESTful API 或 ...
通过结合jQuery与Koa2框架,我们可以较为容易地实现一个前后端分离的应用,前端负责界面展示和用户交互,后端则提供RESTful接口处理业务逻辑。Koa的异步处理能力使服务器的响应更快,用户体验更好。同时,通过Ajax...
例如,使用React Router和后端的路由配合工作。 5. **安全认证与授权**: 实现用户身份验证和权限控制,例如JWT(JSON Web Tokens)可以用来安全地传输用户信息并在前后端之间进行验证。 综上所述,"React-...
学习如何使用Polymer的`<dom-repeat>`、`<paper-button>`等预定义组件,以及如何编写自定义元素是理解此项目的关键。 3. **JavaScript基础**:作为主要编程语言,JavaScript用于处理博客的动态逻辑,如数据绑定、...