我正在尝试自定义 Railsscaffold 命令,以便当我运行时
rails generate scaffold api/v1/model_name
Run Code Online (Sandbox Code Playgroud)
它仍然生成文件夹结构,但不会将 api_v1_ 添加到视图、测试等中。
我了解如何从这篇文章中覆盖和添加新的部分: 覆盖 Rails 脚手架生成器,但我想覆盖测试、工厂和视图。
安装 pq_search 并运行 contrib 包迁移后:
class InstallSomeContribPackages < ActiveRecord::Migration
def up
execute 'CREATE EXTENSION pg_trgm;'
execute 'CREATE EXTENSION fuzzystrmatch;'
end
def down
execute 'DROP EXTENSION pg_trgm;'
execute 'DROP EXTENSION fuzzystrmatch;'
end
end
Run Code Online (Sandbox Code Playgroud)
迁移 dmetaphone 迁移时仍然会抛出错误:
PG::UndefinedFunction: ERROR: function dmetaphone(text) does not exist
LINE 2: SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(rege...
Run Code Online (Sandbox Code Playgroud)