trailblazer/cells

Incorrectly rendering cells

Closed this issue · 8 comments

Hi there.

I have a heavily namespace setup where I have both offer, client/offer, advisor/offer, and admin/offer cells. They all implement the #show method.

When I run cell('advisor/offer', Offer.new), and then cell('offer', Offer.new) it uses the cells/advisor/show.slim everytime.

I would ave expected the second call to use the less nested view in offers/show.slim.

Perhaps I'm missing something. In that case, please enlighten me.

Thanks.

Please use the new constant API: cell(Advisor::Offer, ...). This is a Ruby-problem and not related to Cells.

Excellent. I was missing something. Thanks for the awesomely fast response. I will try that and close the issue if it fixes my problem.

@apotonick doing cell(Advisor::Offer, Offer.new).(:tr) gives me the following error:

NoMethodError - undefined method `call' for #<Class:0x007fe629fcf280>

Stack trace

NoMethodError - undefined method `call' for #<Class:0x007fe629fcf280>
18:37:08 web.1         | Did you mean?  caller
18:37:08 web.1         |                all:
18:37:08 web.1         |    () Users/emil/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/rails-b0b4a9a65861/activerecord/lib/active_record/dynamic_matchers.rb:21:in `method_missing'
18:37:08 web.1         |    () Users/emil/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cells-2462e558b8a0/lib/cell/view_model.rb:31:in `cell'
18:37:08 web.1         |   cells-rails (0.0.6) lib/cell/rails.rb:13:in `cell'
18:37:08 web.1         |   cells-rails (0.0.6) lib/cell/rails.rb:27:in `cell'

Gems

  • cells (4.1.4)
  • cells-rails (0.0.6 71c7d28)
  • cells-slim (0.0.5)
  • rspec-cells (0.3.4)

Am I still doing something wrong?

You simply pass the cell constant to cell, I don't know your app, so Advisor::Offer might be wrong, I don't even know if you use Trailblazer::Cell or Cell::ViewModel, does cell Advisor::OfferCell maybe do the trick?

Thanks for being patient with me ❤️

I'm passing in a simple ActiveRecord class constant and the ActiveRecord instance.

I'm using the ViewModel.

I will investigate further, and try and narrow the issue down.

Ok. I refactored my way around the issue. The initial problem still doesn't seem solved, but I believe it's an issue with the cells-rails app.

You are misunderstanding the API 😉 Whatever your cell class name is, e.g. Advisor::OfferIndexWhateverCell, you have to pass that class into cell.

cell(Advisor::OfferIndexWhateverCell, advisor_model)

Cells doesn't know or care about your ActiveRecord setup, that's why you pass the cell class and the model instance. Ok?

Ohh.. This makes more sense. Thanks for pointing that out. I will try another pass at using it correctly 😉