我使用capybara和rspec运行Rails 4(操作系统是Ubuntu 13.10).我遇到了问题 - 当我运行rspec我的规格工作时,包括使用capybara的fill_in方法的那些.但是在一个规范中,我需要使用capybara的find_field方法,它根本不起作用.它给了我以下错误:
Failure/Error: page.find_field('From:').set(Date.today - 1.month)
Capybara::ElementNotFound:
Unable to find field "From:"
Run Code Online (Sandbox Code Playgroud)
现在,我在page.find_field ...行之前插入了一个"puts page.html"行,它打印的html包含以下行:
<div class="date-range-picker">
<span class="from-date"><label for="from_date">From:</label> <input id="from_date" name="from_date" type="date" value="2013-12-23" /></span>
<span class="to-date"><label for="to_date">To:</label> <input id="to_date" name="to_date" type="date" value="2013-12-30" /></span>
</div>
Run Code Online (Sandbox Code Playgroud)
所以元素在那里,但是没有被find_field方法拾取.有任何想法吗?
我刚刚开始研究 ROR。我严格按照 ROR 官方文档制作了博客应用程序。它适用于 CRDU。现在我向它添加了 Active Admin,它在删除时工作正常,但在创建/更新时出错,专注于 raise ActiveModel::ForbiddenAttributesError
def sanitize_for_mass_assignment(attributes)
if attributes.respond_to?(:permitted?) && !attributes.permitted?
**raise ActiveModel::ForbiddenAttributesError**
else
attributes
end
Run Code Online (Sandbox Code Playgroud)
在控制器中,我使用以下代码:
def create
@article = Article.new(article_params)
if @article.save
redirect_to @article
else
render 'new'
end
end
def update
@article = Article.find(params[:id])
if @article.update(article_params)
redirect_to @article
else
render 'edit'
end
end
def destroy
@article = Article.find(params[:id])
@article.destroy
redirect_to articles_path
end
private
def article_params
params.require(:article).permit(:title, :text, :AuthorAge)
end
Run Code Online (Sandbox Code Playgroud) 我正在尝试在Windows 8(Ruby 1.9.3和Rails 4.0.1)上安装mysql2 gem.我安装了Devkit并且它正常工作,我输入以下内容:
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-conector"'
Run Code Online (Sandbox Code Playgroud)
我以前做过这件事并且它有效,但由于某种原因,这次它抛出了这个奇怪的信息:
Cannot find include dir at C:\mysql-connector\include;C:\mysql-connector\include;C:\mysql-connector/include;
Run Code Online (Sandbox Code Playgroud)
这当然除了整个"由于某种原因无法创建makefile ..."的消息.我正在使用我在这里通过不同帖子找到的mysql连接器 - 在Windows 7上安装Ruby MYSQL2 gem
有谁知道我怎么解决这个问题?我真的需要这个宝石......