Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cells Rails控制台中的开拓者单元_Cells_Trailblazer - Fatal编程技术网

Cells Rails控制台中的开拓者单元

Cells Rails控制台中的开拓者单元,cells,trailblazer,Cells,Trailblazer,如何在Rails控制台中使用“开拓者”单元 概念助手不起作用 irb(main):002:0> c = concept(Resource::Cell, l) NoMethodError: undefined method `concept' for main:Object Did you mean? concern context from (irb):2 concept()&cell()是控制器帮助程序,这意味着如果控制器未加载,它们将无法在控制

如何在Rails控制台中使用“开拓者”单元

概念助手不起作用

irb(main):002:0> c = concept(Resource::Cell, l)
NoMethodError: undefined method `concept' for main:Object
Did you mean?  concern
               context
    from (irb):2
concept()&cell()是控制器帮助程序,这意味着如果控制器未加载,它们将无法在控制台中工作。但你不需要它们

使用cell最简单的方法就是像这样调用它们。您可以使用任何其他ruby对象

单元格

# concepts/song/cell/cell.rb
module Song::Cell
  class Index < Trailblazer::Cell
    def show
      render
    end
  end

  class Show < Trailblazer::Cell
    def show
      render
    end
  end
end
控制台

# Any of the following calls - they are all equivalent pretty much
# The spit html output of the cell
Song::Cell::Show.(Song.last).()
Song::Cell::Show.(Song.last).render
Song::Cell::Show.(Song.last).(:show)
# Any of the following calls - they are all equivalent pretty much
# The spit html output of the cell
Song::Cell::Show.(Song.last).()
Song::Cell::Show.(Song.last).render
Song::Cell::Show.(Song.last).(:show)