trailblazer / cells

View components for Ruby and Rails.
https://trailblazer.to/2.1/docs/cells.html
3.07k stars 236 forks source link

undefined method `template_options_for' #295

Closed EppO closed 9 years ago

EppO commented 9 years ago

Hi,

using Cells 4.0, I get this error

undefined method `template_options_for' for #<TeamMenuCell:0x007fe23aa0b968>

Here is the (very simple) code:

class TeamMenuCell < Cell::ViewModel
  def show
    render
  end

which is called in that view like this:

<%= cell(:team_menu, @team, disabled: "thumbnails")  %>

Reading the code, I assume template_options_for is a support method provided by the template engine, as I'm using ERB, is there any incompatibility with it? Or maybe I'm missing something. Also, after reading the documentation, I have hard time to know how to properly name my cell, should I use Comment::Cell like in the Cell class section or CommentCell like in the Properties section.

samstickland commented 9 years ago

Have you installed the cells-erb gem?

2015-06-22 20:43 GMT+01:00 Florent Monbillard notifications@github.com:

Hi,

using Cells 4.0, I get this error

undefined method `template_options_for' for #TeamMenuCell:0x007fe23aa0b968

Here is the (very simple) code:

class TeamMenuCell < Cell::ViewModel def show render end

which is called in that view like this:

<%= cell(:team_menu, @team, disabled: "thumbnails") %>

Reading the code, I assume template_options_for is a support method provided by the template engine, as I'm using ERB, is there any incompatibility with it? Or maybe I'm missing something. Also, after reading the documentation, I have hard time to know how to properly name my cell, should I use Comment::Cell like in the Cell class section or CommentCell like in the Properties section.

— Reply to this email directly or view it on GitHub https://github.com/apotonick/cells/issues/295.

apotonick commented 9 years ago

https://github.com/apotonick/cells/#installation :wink:

apotonick commented 9 years ago

Thanks @EppO for pointing out the naming inconsistency. I will use the view model naming style throughout the README, the concept style and the benefits are well documented in the Trailblazer book in the Cells chapter. :+1:

EppO commented 9 years ago

I feel ashamed of myself... Didn't read the README carefully enough after upgrading from Cells 3.x Thank you for pointing out my mistake.

apotonick commented 9 years ago

Thanks to you for spotting the README inconsistency! Did you see your mention in the commit? :wink: The Installation section is kinda hidden, maybe we should move it up?

EppO commented 9 years ago

Yeah I've seen it :) I would definitely put the Installation chapter before the Usage one, and I'm willing to do it to redeem myself.

apotonick commented 9 years ago

I find that the introduction reads very well and a long Installation section interrupts the flow, though?

EppO commented 9 years ago

I'm maybe wrong but I think that when you land in cells github page, you already know what you want because you read a blog post about it or you used cells 3.x, so what you're looking for is a quick working setup to start playing with cells. But I agree that all depends on what role you want this github page to fulfill.

EppO commented 9 years ago

And links to blog posts in a resources section like the book for example could be a useful option for someone looking for a good introduction to cells.

apotonick commented 9 years ago

Good idea about the resource links, even though, I would like people to buy the book. :wink:

Yeah, true, it's a hard thing to figure out. 50% expect your README to be an awesome introduction with code samples, and the other 50% wants it to be full-blown documentation covering the entire API, and the other 50% expect both of it plus a complete wiki.

I'm one of the first group: when I browse gems, I check the README and if I can't find instant code snippets to understand (I mostly don't even really read text) I "lose interest" and might move on.

Maybe be can leave the generator section where it was and move just Installation further up?