如何在动作文本中添加正文?
Post.rb
has_rich_text :body
test / fixtures / posts.yml
one:
name: <%= Faker::Name.unique.name %>
body: "body"
posts_controller_test.rb
require 'test_helper'
class PostsControllerTest < ActionDispatch::IntegrationTest
setup do
@post = posts(:one)
end
test "should get index" do
get posts_url
assert_response :success
end
end
我运行了PostsControllerTest预期的成功响应,但是得到了
Minitest::UnexpectedError: ActiveRecord::Fixture::FixtureError: table "posts" has no columns named "body"
。
使用Rails 6.0,Ruby 2.7.1
答案 0 :(得分:2)
创建文件
测试/装置/action_text/rich_texts.yml
如果它不存在,则向其中添加以下行:
0.7
您还应该从 test / fixtures / posts.yml 中删除post_one:
record: one (Post) # record: record name (in_yml) in association (ModelName)
name: body # has_rich_text :name_of_rich_text_attribute
body: <p>Lorem ipsum dolor sit amet.</p> # actual rich text content
。
答案 1 :(得分:-1)
我没有解决方案,但有解决方法,如果您未在灯具中设置Action_Text主体,则不会由于缺少表而失败。 如果您发布一个像这样的字符串
,它就可以工作var
mark: TDictionary<Integer, Integer>;
function digitsum(x, y: integer): integer;
begin
if mark.ContainsKey((x + 1000) * 2000 + y + 1000) then
Exit(9999);
Result := 0;
x := abs(x);
y := abs(y);
while y > 0 do begin
Result := Result + y mod 10;
y := y div 10;
end;
while x > 0 do begin
Result := Result + x mod 10;
x := x div 10;
end;
end;
function flood(x, y: integer): integer;
begin
if digitsum(x,y) > 23 then
Exit(0);
Result := 1;
mark.Add((x + 1000) * 2000 + y + 1000, 0);
Canvas.Pixels[x, y] := clWhite;
Inc(Result, flood(x + 1, y));
Inc(Result, flood(x - 1, y));
Inc(Result, flood(x, y - 1));
Inc(Result, flood(x, y + 1));
end;
begin
Canvas.Brush.Color := clBlack;
Canvas.FillRect(ClientRect);
mark:= TDictionary<Integer, Integer>.Create;
Caption := flood(0, 0).ToString;
创建方法