Tag: 按钮

button_to没有从params hash传递正确的id

button_to未将正确的id传递给line_item。 在下面的日志中,您会看到bike_id从正确的’86’变为不正确的’1’(巧合的是我的user_id)。 任何帮助,将不胜感激。 下面是我的development.log中的错误,然后是我的视图和控制器中的代码。 谢谢。 development.log Started POST “/line_items?bike_id=86” for 127.0.0.1 at 2011-08-01 18:09:52 -0400 DEPRECATION WARNING: Setting filter_parameter_logging in ActionController is deprecated and has no longer effect, please set ‘config.filter_parameters’ in config/application.rb instead. (called from at /Users/willdennis/rails_projects/spinlister/app/controllers/application_controller.rb:8) Processing by LineItemsController#create as HTML Parameters: {“authenticity_token”=>”5GYQqvf7U5awhLrZ9Aw910ETf2kqOk3PI315jkjEfMU=”, “bike_id”=>”86”} [1m[35mCart Load (0.6ms)[0m SELECT “carts”.* FROM “carts” WHERE (“carts”.”id” […]

将function附加到导轨3中的按钮

我的网页上有一组按钮。 单击其中一个按钮的效果需要是调用外部API(可能是收到的响应,并更新页面上的内容)。 一些附加信息:这些按钮由部分放置在页面上,并构成用户列表的一部分。 这些按钮用于激活和停用列出的用户。 我不确定这种设置是否会影响我做我想做的最佳方法,所以我认为值得一提。 该怎么做? 按钮是否应该链接到我的rails应用程序中的某个控制器? 当按钮被击中时,是否需要重新加载页面? 我可以将该请求卸载到ajax吗?等。 我不知道解决这个问题的最佳方法,任何指导都会certificate是非常宝贵的。

:确认导轨无法正常工作

我刚刚开始使用ruby在rails上进行编码,而且我一直在关注使用比我正在使用的更过时版本的rails的指南。 我正在使用3.2.12 这是我的代码: “delete”, :confirm => ‘Are you sure?’ %> 根据我的理解,这些是传递给rails的符号,然后转换为html或javascript操作,然后弹出消息框并删除对象(如果适用)。 上面的代码会破坏对象,但不会弹出确认框。 为什么是这样? 另外,我首先得到以下内容: “delete”, :confirm => ‘Are you sure?’ %> 在任何情况下,使用link_to或button_to都不会弹出确认框。 下面是使用Chrome检查器检查时呈现的html。 jquery和jquery-ujs也加载到了这里,所以我不知道从哪里开始。 谢谢!

将link_to更改为button_to时,“没有路由匹配”

我有这段代码: “button” %> 哪个工作正常,但当我改成它时, “button” %> 我收到这个错误 没有路由匹配[POST]“/ users / new” 任何帮助都将不胜感激。

除非我刷新页面form_for Rails,否则提交按钮不起作用

我有一个有问题模型的应用程序,当我去创建一个记录时,提交按钮什么都不做。 除非我刷新页面并尝试再次添加它,否则没有错误只是根本不执行。 当我更新记录时也会发生同样的情况。 这是我的控制器 class ProblemsController < ApplicationController include Concerns::Votes def index @problems = Problem.all end def show @problem = find_problem end def new @problem = Problem.new end def edit @problem = find_problem end def create @problem = current_user.problems.new(problem_params) @problem.save redirect_to @problem end def update @problem = find_problem if @problem.update_attributes(problem_params) redirect_to @problem else redirect_to @problem […]

Haml:link_to vs button_to

据我所知, link_to用于get方法, button_to用于post方法。 另一方面,我被告知使用HTML5语义, 用于任何类型的可点击…好吧,按钮。 如果我有一个可点击按钮,将用户发送到表单填写,我应该创建一个button_to还是link_to ?

使用ruby / Selenium上传文件

我正在写一个脚本,我点击一个按钮(选择照片),打开文件上传(资源管理器)框。 我如何设置我的文件名? 这是我用来点击选择照片按钮(ruby)的代码 driver.find_element(:id, “fileUploadButton”).click 我看过一些post说我不需要点击按钮,而是将路径发送到我要上传的文件/图像。 那么如何在c:\ temp \ mypicture.jpg上传文件? 这是我完整而简单的代码。 driver.navigate.to “http://blah blah” #the real site is an internal site driver.find_element(:id, “claimGiftButtonDesktop”).click sleep 5 driver.find_element(:id, “fileUploadButton”).click 单击fileUploadButton后,就会显示资源管理器窗口。 如果我手动点击打开或双击它,然后显示加载模式,图像显示在网站上。 这是一个有效的IDE录音。 我只是在将此转换为ruby时遇到问题。 open /PromoSite click id=claimGiftButtonDesktop click id=fileUploadButton type id=fileInputElem #Value C:\\temp\\file.jpg click id=viewProductPreviewButton 我还添加了一个屏幕截图。 我单击按钮,显示文件上传。 这应该是容易的,所以我不能专注于正确的id。

Ruby on Rails中的Button_to路线不好

我正在尝试使用button_to rails helper。 我写了以下代码: ‘mark-button’ %> 并收到以下错误消息 No route matches “/items/1/edit” 但是当我刷新页面时,它会进行相应的操作。 我得到的页面的URL是localhost:3000/items/1/edit ,这是正确的URL。 如果我将button_to命令切换到link_to加载的页面没有错误。 意思是这段代码: ‘mark-button’ %> 加载很好。 也许有一些我不知道的button_tofunction,但我迷路了。