Closed sath01 closed 6 years ago
Hi Steve,
what's your cell's class name (full constant path, please)? Maybe paste the entire cell class file here, along with where it's stored.
Hey Nick - thanks for the quick response.
Cell is:
module User::Cell
class Index < Trailblazer::Cell
def no_items
return "No Users" if model.size == 0
end
end
end
And lives in: app/concepts/user/cell/index.rb Hope that's what you wanted to know.
Yepp, looks correct, and now, show me how you invoke that cell.
From the UsersController ...
def index
run User::Index
render cell(User::Cell::Index, result["model"]), layout: false
end
I have tried different layout options as well.
result["model"] is ...
#<ActiveRecord::Relation [#<User id: 1, email: "xxxx@yyy.com", other_attributes_here>]>
There is only one user at the moment.
So where does the view
template name come from? :thinking: Because User::Cell::Index
, being a TRB::Cell
, will try to render app/concepts/user/view/index.haml
per default.
It must be a problem in that view, can you paste it?
Yep, view template is in: app/concepts/user/view/index.haml and is standard haml ...
- @title = "Listing Users"
- content_for :description do
%p Users registered on this site.
- content_for :actions do
= action_page_header new_user_path, 'Add User', 'plus'
.row
.col-xs-12.col-sm-12.col-md-12.col-lg-12
.sheet.sheet-condensed
.sheet-inner
%table.table
%thead
%tr
%th Email
%th
%tbody
etc ...
Ok, so first of all, setting @instance
variables is a no-go. That's just so wrong. Second, content_for
is not supported in Cells, because it breaks with the idea of encapsulation.
What happens when you just say "hello!" in that template?
Fair enough.
Changed index.haml to:
- %h1 Hello World
Same error.
Correct me if I'm wrong, but is - %h1 ...
valid HAML?
Oops. Your quite right - slip of the keyboard. Changed the template to ...
%h1 Hello World
Same issue.
As I said, I also cloned your own sample app, bundled with a fresh install and got the same error, with your templates. Seems to be more than the haml template structure or location?
Just not sure why I'm the only one getting it.
Hi! Which app did you clone?
Hi Nick,
It was: https://github.com/trailblazer/guides/tree/operation-03
Hey Nick. Any thoughts for me on this error. I'd love to use cells, but I guess I can just use normal rails renderer.
The example app works for me, just checked. Is it maybe that the example app is using Slim while you're trying to use Haml? Have you tried with .slim
?
Will give it a go.
Cheers.
If you want to use Haml, remove cells-slim
from the Gemfile and replace with cells-haml
(http://trailblazer.to/gems/cells/api.html#template-formats). Don't worry, we'll get you on da cells.
Yep, have done that. As per previous comment ...
Here is my gem setup ... rails (5.1.4) cells (4.1.7) cells-haml (0.0.10) cells-rails (0.0.6) reform-rails (0.1.7) trailblazer-rails (1.0.4) haml-rails (1.0.0)
I might try slim and hamlit as well - see if they make a difference. I'll let you know.
Nick,
Updated to the latest gems, and all seems to be ok now.
trailblazer-rails 1.0.5 (was 1.0.4) dry-core 0.4.3 (was 0.4.2) cells-rails 0.0.8 (was 0.0.6)
Even HAML is working. Thanks for your help with this.
Cheers,
Steve.
:metal:
Hi people! I encountered the same issue with Cells (Template missing: view: * prefixes: *
) and my search engine brought me there. I just had to rm -rf tmp/cache/
to fix the issue. Have a nice day!
Sorry for repeating an issue, but I've wrapped my (rather small) mind around a pole trying to find a solution, and I would really like to use Trailblazer Cells.
It's the old "Template Missing" issue again. Just a reminder - the error is ...
Template missing: view:
index.hamlprefixes: ["app/concepts/user/view"]
I have both index.haml and index.html.haml in app/concepts/user/view, but still gives me the error.
I have back-traced and I think it's the line ...
template_for(prefixes, view, template_options) or raise TemplateMissingError.new(prefixes, view)
in find_template - cells (4.1.7) lib/cell/view_model.rbThe template is there, but the 'template_for' isn't resulting in any output, which triggers the raise. The index.xxx files are definitely haml files.
I also github cloned and tested the Trailblazer test app, and it gave the same error.
Here is my gem setup ... rails (5.1.4) cells (4.1.7) cells-haml (0.0.10) cells-rails (0.0.6) reform-rails (0.1.7) trailblazer-rails (1.0.4) haml-rails (1.0.0)
Thanks (in advance) for the help, and thanks for creating the trailblazer philosophy and code. It's exactly what rails needs.
Steve.