草庐IT

page_edit

全部标签

ruby-on-rails - 雷未定义方法 `total_pages'

在使用kaminari时,我遇到了一个错误。gem文件:#gem'will_paginate','~>3.0.6'#gem'will_paginate-bootstrap'gem'kaminari'列表Controller.rbdefindexifparams[:tag]@lists=List.tagged_with(params[:tag]).order(created_at::desc).paginate(page:params[:page],per_page:3)else@lists=List.all.order(created_at::desc)endend我还使用.pagep

ruby - 如何将变量传递给 capybara 中的 page.executescript()

我需要在javascript中传递要通过capybara中的excute_script方法执行的变量。我无法将变量传递给它。请任何人帮助我。例子:@idd="sample"txt=page.execute_script('varuser_id=${@idd};returnuser_id;')putstxt我希望打印文本示例,但我遇到了Java脚本错误。 最佳答案 我认为问题出在${};你必须使用#{};尝试:page.execute_script("varuser_id='#{@idd}';returnuser_id;")

ruby-on-rails - Hartl 教程中的 bundle exec rspec spec/requests/static_pages_spec.rb 不起作用

我正在按照MichaelHartl的ruby​​onrails教程测试示例应用程序(3.2.1测试驱动开发),但在键入bundleexecrspecspec/requests/static_pages_spec.rb后出现以下错误/home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:in`require':cannotloadsuchfile--zip/zip(LoadErr

ruby-on-rails - 文章中的 ActionController::UrlGenerationError#edit

我收到以下错误:没有路由匹配{:action=>"show",:controller=>"articles",:id=>nil}缺少必需的键:[:id]以下是显示错误的代码。这是什么错误,每当我从上一个屏幕点击编辑时,我想我正在发送文章ID。这是我的rake路由输出PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articl

ruby - Mailchimp API 未替换 mc :edit content sections (using ruby library)

我在用我提供的内容替换Mailchimp中的mc:edit内容区域时遇到问题。电子邮件已发送给订阅者,但所提供的内容均未添加到电子邮件中。谁能看出我可能哪里出错了?这是我正在使用的脚本:campaign=mailchimp.campaigns.create("regular",{"list_id"=>list_id,"subject"=>"EmailTest","from_email"=>"edward@somewhere.com","from_name"=>"Edward","to_name"=>"Thetoname","template_id"=>35089},{"sections

ruby - 如何将 octopress 3 部署到现有 gh-pages 站点中的子目录?

我正在使用Octopress3,当我运行jekyllbuild时,它会生成正确的文件集(包括我的静态文件,请参阅下面的文件列表):$cd_site:_site$ls-a.CNAMEassetsgoogle2d8.htmlindex-alternative.html..aboutblogincrease-revenue.htmlindex.html请注意,我的整个jekyll生成的blog现在都安全地存储在\blog\中,这正是我想要的。但是一旦我执行octopressdeploy,它就会覆盖整个文件夹(这也会覆盖我现有的静态文件),请参见下面的list:$cd_site:_site$l

ruby-on-rails - 在 Rails 3 中使用 current_page 时为 "No routes matches"

有没有人遇到过使用current_page时路由神秘地变得无法检测到?在Rails3中?即使使用包含路由、View和Controller的完全生成的脚手架,我也会收到“无路由匹配”错误。代码如下:ifcurrent_page?(:controller=>'users',:action=>"show")如果我向routes.rb添加一个“匹配”命令,它工作正常,但如果资源已经创建,为什么我需要这样做呢?我错过了什么? 最佳答案 如果你只是想测试当前的Controller,你可以这样做:ifparams[:controller]=='u

ruby-on-rails - save_and_open_page 和 spork,spork 正在丢失测试套件/输出

当我用spork运行我的rspec测试时,每次我使用capybara的save_and_open_page时,spork都会丢失测试套件......或者可能不再输出任何东西......查看日志#=>withoutsave_and_open_page09:04:24-INFO-SporkserverforRSpec,Test::Unitsuccessfullystarted09:04:24-INFO-Guard::RSpecisrunning09:04:24-INFO-RunningallspecsRunningtestswithargs["--drb","-f","progress",

ruby-on-rails - ruby rails : How would i stay on the same page if the post is not saved?

defcreate@addpost=Post.newparams[:data]if@addpost.saveflash[:notice]="Posthasbeensavedsuccessfully."redirect_toposts_pathelseflash[:notice]="Postcannotbesaved,pleaseenterinformation."endend如果帖子未保存,则会重定向到http://0.0.0.0:3000/posts,但我需要留在页面上,带有文本输入字段,以便用户可以输入数据。后模型classPosttruevalidates:content,:pr

ruby - 在 rails_admin 中,如何关闭相关子表单中的 "add new"和 "edit"按钮?

我想阻止人们从子表单中添加或编辑页面布局。基本上我想关闭下面截图中的按钮:我能做到这一点,还是必须在全局范围内关闭对整个页面布局模型的添加和编辑? 最佳答案 可能有点晚了,但你可以使用inline_add和inline_edit。例子:field:profiledoinline_addfalseinline_editfalseend 关于ruby-在rails_admin中,如何关闭相关子表单中的"addnew"和"edit"按钮?,我们在StackOverflow上找到一个类似的问题: