草庐IT

ACTION_REQUEST_DISCOVERABLE

全部标签

ruby-on-rails - rails : How to determine controller/action in view

这是我的部分表格:{:multipart=>true}do|d|%>'Uploadlogo',:required=>false%>'Image,:required=>false',:style=>'margin-bottom:2px'%>'BilledURL',:required=>false%>如果操作是编辑,我想改为显示:{:multipart=>true}do|d|%>'Uploadlogo',:required=>false%>'Image,:required=>false',:style=>'margin-bottom:2px'%>'BilledURL',:required=

ruby - 如何在 OpenURI 中指定 "http request header"

我正在尝试使用Ruby的OpenURIgem调用URL,但是它需要我在其HTTP请求header中传递某些值。知道怎么做吗? 最佳答案 根据thedocumentation,您可以将httpheader的哈希值作为第二个参数传递给open:open("http://www.ruby-lang.org/en/","User-Agent"=>"Ruby/#{RUBY_VERSION}","From"=>"foo@bar.invalid","Referer"=>"http://www.ruby-lang.org/"){|f|#...}

ruby - Rack::Request - 如何获取所有 header ?

标题是不言自明的。有什么方法可以获取header(Rack::Request.env[]除外)? 最佳答案 HTTPheader在Rackenvironment中可用。传递给您的应用:HTTP_Variables:Variablescorrespondingtotheclient-suppliedHTTPrequestheaders(i.e.,variableswhosenamesbeginwithHTTP_).Thepresenceorabsenceofthesevariablesshouldcorrespondwiththepr

ruby-on-rails - 没有参数的 request.fullpath

request.fullpath给出完整路径加上传递的任何参数,例如/page?param1=value¶m2&value如何只获取没有参数的页面?喜欢/page谢谢。 最佳答案 使用路径代替完整路径。虽然没有记录,request.path对我有用。我通常使用我的插件rails_web_console来处理请求对象。更新:正如turboladen注意到的那样,"[ActionDispatch::Request][2]继承自[Rack::Request‌][3],其中request.path为定义”。path没有记录在那里,但

ruby-on-rails - rake 路由错误 "Missing :action key on routes definition"

我得到了$rakeroutesrakeaborted!ArgumentError:Missing:actionkeyonroutesdefinition,pleasecheckyourroutes./usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.1.5/lib/action_dispatch/routing/mapper.rb:243:in`default_controller_and_action'/usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.1.5/lib/action_dispa

ruby-on-rails - Errno::ECONNREFUSED:连接被拒绝 - connect(2) for action mailer

我长期以来一直在使用Rails。现在我在ActionMailer中遇到了一个小问题。我想在用户注册时发送一封电子邮件以确认他的注册。我可以在开发模式下发送电子邮件,但在生产模式下不能。异常Errno::ECONNREFUSED:Connectionrefused-connect(2)每次调用deliver方法时都会出现。我写了下面的代码。我的SMTP配置如下:config.action_mailer.default_url_options={:host=>"localhost:3000"}config.action_mailer.delivery_method=:smtpconfig.

ruby-on-rails - 如何设置 ActionMailer default_url_options 的 :host dynamically to the request's hostname?

我正在尝试设置:hostforactionmailer默认url选项。我在所有环境文件中设置了以下内容config.action_mailer.default_url_options={:host=>"localhost"}我想通过提供请求主机使其更具动态性。当我尝试通过设置它时config.action_mailer.default_url_options={:host=>request.domain}或config.action_mailer.default_url_options={:host=>request.env["SERVER_NAME"]}它抛出错误...无法识别“请求

ruby - Action Controller ::未知格式

在我的Rails应用程序中,我向服务器发出了一个ajax请求,以存储一些数据。这曾经没有任何问题,但现在我得到一个错误:ActionController::UnknownFormat(ActionController::UnknownFormat):app/controllers/reservations_controller.rb:45:in`create'如下是Controller和我声明数据类型为JSON的javascript文件classReservationController函数.js$.ajax({url:url_link,dataType:'json',type:'PO

ruby-on-rails - 如何用简单的形式定义 Action ?

我正在尝试在admin/photographersController中定义操作“savenew”。我试过这个:'savenew',:id=>params[:id],:multipart=>true)do|f|%>但是表单中的action还是:/admin/photographers什么时候应该是:/admin/photographers/savenew 最佳答案 您有没有为此使用REST的原因?它会让你的生活更轻松,并且需要更少的代码。如果您打算使用此自定义操作,则需要指定url和可能的方法:savenew_photographe

ruby-on-rails - Rails 中的 request.remote_ip 和 request.ip 有什么区别?

如题所示,两种方法都可以获取到客户端的ip。我想知道是否有任何差异。谢谢。源码里有"/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.3/lib/action_dispatch/http/request.rb"257L,8741Cdefip@ip||=superend#OriginatingIPaddress,usuallysetbytheRemoteIpmiddleware.defremote_ip@remote_ip||=(@env["action_dispatch.remote_ip"]||ip).to_send但我真