Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template Missing ... again! #462

Closed
sath01 opened this issue Jan 23, 2018 · 21 comments
Closed

Template Missing ... again! #462

sath01 opened this issue Jan 23, 2018 · 21 comments

Comments

@sath01
Copy link

sath01 commented Jan 23, 2018

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.haml prefixes: ["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.rb

The 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.

@apotonick
Copy link
Member

apotonick commented Jan 23, 2018

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.

@sath01
Copy link
Author

sath01 commented Jan 24, 2018

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.

@apotonick
Copy link
Member

Yepp, looks correct, and now, show me how you invoke that cell.

@sath01
Copy link
Author

sath01 commented Jan 24, 2018

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.

@apotonick
Copy link
Member

apotonick commented Jan 24, 2018

So where does the view template name come from? 🤔 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?

@sath01
Copy link
Author

sath01 commented Jan 24, 2018

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 ...

@apotonick
Copy link
Member

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?

@sath01
Copy link
Author

sath01 commented Jan 24, 2018

Fair enough.

Changed index.haml to:

- %h1 Hello World

Same error.

@apotonick
Copy link
Member

Correct me if I'm wrong, but is - %h1 ... valid HAML?

@sath01
Copy link
Author

sath01 commented Jan 25, 2018

Oops. Your quite right - slip of the keyboard.
Changed the template to ...

%h1 Hello World

Same issue.

@sath01
Copy link
Author

sath01 commented Jan 25, 2018

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.

@apotonick
Copy link
Member

Hi! Which app did you clone?

@sath01
Copy link
Author

sath01 commented Jan 29, 2018 via email

@sath01
Copy link
Author

sath01 commented Feb 6, 2018

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.

@apotonick
Copy link
Member

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?

@sath01
Copy link
Author

sath01 commented Feb 6, 2018 via email

@apotonick
Copy link
Member

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.

@sath01
Copy link
Author

sath01 commented Feb 6, 2018

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.

@sath01
Copy link
Author

sath01 commented Feb 9, 2018 via email

@apotonick
Copy link
Member

🤘

@Bahanix
Copy link

Bahanix commented Oct 8, 2019

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants