How can I work with a Trailblazer cell in the Rails console?
The concept helper doesn't work
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() are Controller helpers, meaning they wouldn't work in console if the controller is not loaded. But you don't need them !
The easiest way to play with cell is just to invoke them like . you would with any other ruby object.
Cell
# 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
View
%h1
Song#show
%p
Find me in app/concepts/song/view/show.haml
Console
# 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)