在这种情况下如何单击第一个链接:
<div class="item">
<a href="/agree/">Agree</a>
</div>
<div class="item">
<a href="/agree/">Agree</a>
</div>
Run Code Online (Sandbox Code Playgroud)
within ".item" do
first(:link, "Agree").click
end
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Capybara::Ambiguous:
Ambiguous match, found 2 elements matching css ".item"
Run Code Online (Sandbox Code Playgroud)
没有within我得到这个错误:
Failure/Error: first(:link, "Agree").click
NoMethodError:
undefined method `click' for nil:NilClass
Run Code Online (Sandbox Code Playgroud) 当我在Vim中执行Rmodel,Rcontroller和其他人时.我只看到白色文字.但是,当我去到下一个缓冲区,然后回去:bn和:bl,颜色都在工作.
这是我的.vim文件夹 https://github.com/regedarek/dotvim
现在要复制到系统剪贴板,我必须通过键在tmux窗口中通过鼠标文本进行选择Shift.然后我必须运行此命令:
tmux save-buffer - | reattach-to-user-namespace pbcopy
Run Code Online (Sandbox Code Playgroud)
是否有机会更轻松地保存到系统剪贴板?密钥绑定或更好地在Shift发布后自动执行此操作.
我的tmux配置:https://gist.github.com/3641580
我曾经使用ZoomWin:https://github.com/vim-scripts/ZoomWin在Vim中的一个和多个窗口之间切换.但这个插件有一个大问题.当我试图恢复多个窗口(垂直分割)时,延迟大约2-4秒.
你知道如何避免这种滞后吗?或者也许是更好的解决方案.
版本25解决了问题:https://github.com/regedarek/ZoomWin
我在为FZF vim插件中的最新文件找到合适的解决方案时遇到问题.
这个插件应具有以下功能:
我试过两个解决方案
command! FZFMru call fzf#run({
\ 'source': reverse(s:all_files()),
\ 'sink': 'edit',
\ 'options': '-m --no-sort -x',
\ 'down': '40%' })
function! s:all_files()
return extend(
\ filter(copy(v:oldfiles),
\ "v:val !~ 'fugitive:\\|\\.svg|NERD_tree\\|^/tmp/\\|.git/'"),
\ map(filter(range(1, bufnr('$')), 'buflisted(v:val)'), 'bufname(v:val)'))
endfunction
Run Code Online (Sandbox Code Playgroud)
这个在打开会话期间工作,但是当我重新启动vim时,我没有看到所有上次打开的文件.
command! FZFMru call s:fzf_wrap({
\'source': 'bash -c "'.
\ 'echo -e \"'.s:old_files().'\";'.
\ 'ag -l -g \"\"'.
\ '"',
\})
function! s:fzf_wrap(dict)
let defaults = {
\'sink' : 'edit',
\'options' : '+s -e -m',
\'tmux_height': '40%',
\}
call …Run Code Online (Sandbox Code Playgroud) 当我跑步时,bundle install我得到了
An error occurred while installing libv8 (3.11.8.17), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.11.8.17'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)
Libv8是依赖lunchy和therubyracer宝石.
我锁定了我的Gemfile.locklibv8 gem3.11.8.17
但我发现我可以将它降级为 3.3.10.4
bundle install/update:libv8(therubyracer)安装失败(带有本机扩展)
怎么做?
我也找到了工作3.11.8.17宝石,但不知道如何在我的系统上实现它.
https://github.com/cowboyd/libv8/issues/107#issuecomment-26146673
我正在使用jquery-fileupload-rails来上传多个文件.
我希望能够设置文档名称并向其添加多个附件.
但是现在当我选择3个附件时,documents每个附件创建3 个附件.
我想我需要改变某种形式来添加附件.我添加了多个选项和编码名称.
我想使用这个插件,因为稍后我会想要添加拖放功能.
从
= simple_form_for [:member, @document], html: { multipart: true } do |f|
= f.input :name
= f.simple_fields_for :attachments, Attachment.new do |a|
= a.file_field :attachment, multiple: true, name: "document[attachments_attributes][][attachment]"
= f.submit
Run Code Online (Sandbox Code Playgroud)
生成:
<input id="document_attachments_attributes_0_attachment" multiple="multiple" name="document[attachments_attributes][][attachment]" type="file">
Run Code Online (Sandbox Code Playgroud)
JS
jQuery ->
$('#new_document').fileupload()
Run Code Online (Sandbox Code Playgroud)
楷模
class Document < ActiveRecord::Base
has_many :attachments
accepts_nested_attributes_for :attachments
end
class Attachment < ActiveRecord::Base
belongs_to :document
has_attached_file :attachment
end
Run Code Online (Sandbox Code Playgroud)
调节器
class Member::DocumentsController < ApplicationController
def new
@document = Document.new
end …Run Code Online (Sandbox Code Playgroud) ruby jquery ruby-on-rails nested-attributes jquery-file-upload
我有以下型号
楷模
Job
belongs_to :company
Company
has_many :jobs
Run Code Online (Sandbox Code Playgroud)
现在我使用以下方法选择所有Jobs 已接受Company的:
def self.with_accepted_company
Job.all.reject {|job| job.company.state != "accepted" }
end
Run Code Online (Sandbox Code Playgroud)
但是我想使用范围并将其与其他范围一起使用.是否可以在Job模型中编写该范围?
我知道如何将Rails中的表导出为格式化Excel文件:http://railscasts.com/episodes/362-exporting-csv-and-excel
但是如何从控制台做到这一点.
我想用这样的东西:
def answer_params
params.require(:answer).permit!.without(:user_id)
end
Run Code Online (Sandbox Code Playgroud)