rails 重构模型给出了 Cannot rename instance variable '@search' to local 'rl_search' 的错误
rails refactor model gives an error of Cannot rename instance variable '@search' to local 'rl_search'
我需要重构我的 table 以便 table 名称具有前缀。 IE。搜索次数变为 rl_searches。
当我运行将searches.rb重构为rl_searches.rb时,我得到了
的错误
Cannot rename instance variable '@search' to local 'rl_search'
如果我在一个视图中显示冲突,一个例子是:
def destroy
@search.destroy
respond_to do |format|
format.html { redirect_to searches_url, notice: 'Search was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_search
@search = Search.find(params[:id])
end
我最初的想法是我可以重构模型而不是强制重构变量。那行得通吗?
是的,您可以显式设置 table name
class Search < ActiveRecord::Base
def self.table_name
"rl_" + super
end
end
我需要重构我的 table 以便 table 名称具有前缀。 IE。搜索次数变为 rl_searches。
当我运行将searches.rb重构为rl_searches.rb时,我得到了
的错误Cannot rename instance variable '@search' to local 'rl_search'
如果我在一个视图中显示冲突,一个例子是:
def destroy
@search.destroy
respond_to do |format|
format.html { redirect_to searches_url, notice: 'Search was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_search
@search = Search.find(params[:id])
end
我最初的想法是我可以重构模型而不是强制重构变量。那行得通吗?
是的,您可以显式设置 table name
class Search < ActiveRecord::Base
def self.table_name
"rl_" + super
end
end