小编ast*_*ohn的帖子

rails fields_for使用多个本地生成部分生成未定义变量的部分

所有,

我遇到了标准fields_for设置的问题.在我的"_form"部分我有:

<div class="comment_list">
  <%= f.fields_for :comments do |cf| %>
    <%= render :partial => 'comments/comment_fields', :locals => {:f => cf, :tester => true} %>
  <% end %>

  <%= link_to_add_fields "Add a comment", f, :comments %>
</div>
Run Code Online (Sandbox Code Playgroud)

在"_comment_fields"部分中,我有通常的字段,然后是我的测试变量:

<%= tester.to_s %>
Run Code Online (Sandbox Code Playgroud)

当我删除测试器变量时,一切都运行良好.一旦我添加测试变量,我就会收到此错误:

ActionView :: Template :: Error(#Class的未定义局部变量或方法`tester':0xa1f3664>:0xa1f1bd4>)

有没有其他人在使用具有多个本地的fields_for时遇到此问题?


为了详细说明,我的"_comment_fields"部分看起来像这样:

<div class="comment dynamic_field">
  <span class="comment_content"><%= f.text_field :content, :class => "comment_content" %></span>
  <%= tester.to_s %>
  <%= link_to_remove_fields "remove", f %>
</div>
Run Code Online (Sandbox Code Playgroud)

它仅从"_form"部分调用.

ruby-on-rails partial locals ruby-on-rails-3

10
推荐指数
1
解决办法
7494
查看次数

Rails3,Cucumber,Capybara,文件上传=>内容正文(EOFError)?

我很难让简单的文件上传测试工作.我在使用Cucumber和Capybara的ruby 1.9.2上使用Rails 3.0.0.

视图:

<%= form_tag "/upload/create", :multipart => true do %>
  <label for="file">File to Upload:</label>
  <%= file_field_tag "file" %>
  <%= submit_tag "Upload" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)

黄瓜步骤:

When /^I upload the basic file$/ do  
  visit path_to("upload")
  path = File.join(::Rails.root, "somefile") 
  attach_file("file", path)
  click_button("Upload")
end
Run Code Online (Sandbox Code Playgroud)

在我的控制器中,除了:

def create
  file = params[:file]
end
Run Code Online (Sandbox Code Playgroud)

Gemfile片段:

group :development, :test do
  # testing with specs
  gem "ZenTest", ">= 4.3.3"
  gem "autotest"
  gem "rspec-rails", ">= 2.0.0.beta.19", :git => "git://github.com/rspec/rspec-rails.git"
  gem "rspec", :git => "git://github.com/rspec/rspec.git"
  gem …
Run Code Online (Sandbox Code Playgroud)

file-upload cucumber capybara ruby-on-rails-3

8
推荐指数
1
解决办法
8027
查看次数

设置事务隔离级别时的 Phoenix / Elixir 测试

我有一段代码,看起来像这样:

Repo.transaction(fn ->
  Repo.query!("set transaction isolation level serializable;")

  # do some queries

end)
Run Code Online (Sandbox Code Playgroud)

在我的测试套件中,我不断遇到错误:

(Postgrex.Error) ERROR 25001 (active_sql_transaction): SET TRANSACTION ISOLATION LEVEL must be called before any query
Run Code Online (Sandbox Code Playgroud)

我想知道我是否在做一些根本性错误的事情,或者是否缺少有关测试环境的某些内容。

谢谢!

postgresql elixir ecto phoenix-framework postgrex

7
推荐指数
2
解决办法
902
查看次数

Xamarin:绑定ios协议/委托不能访问在structs.cs中定义的枚举

我目前正在为EDQueue库创建ios绑定.

Structs.cs文件看起来像这样:

using System;
using ObjCRuntime;

namespace EDQueue
{


    // => Enums attributed with[NativeAttribute] must have an underlying type of `long` or `ulong`
    [Native]
    public enum EDQueueResult : long
    {
        Success = 0,
        Fail,
        Critical
    }

}
Run Code Online (Sandbox Code Playgroud)

ApiDefinition.cs文件类似于:

using System;
using Foundation;
using ObjCRuntime;

namespace EDQueue
{
    // typedef void (^EDQueueCompletionBlock)(EDQueueResult);
    delegate void EDQueueCompletionBlock(EDQueueResult result);

    // ETC....

    // @protocol EDQueueDelegate <NSObject>
    [Protocol, Model]
    [BaseType(typeof(NSObject))]
    interface EDQueueDelegate
    {
        // @optional -(EDQueueResult)queue:(EDQueue *)queue processJob:(NSDictionary *)job; …
Run Code Online (Sandbox Code Playgroud)

c# binding xamarin.ios ios xamarin

5
推荐指数
1
解决办法
407
查看次数