-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
I like Cells gem for Rails very much, the only thing I do not like it the syntax. For example I find
cell(:post,post).(:title_with_date)
very ugly. I respect, that the author has his own syntac preference, I just want to be able to make it more rubyish for my purposes. Alternative syntax
PostCell.(post).(:title_with_date)
is slightly better, but I would prefer something like
post.cell.title_with_date
or at least post.cell(:title_with_date). I tried to implement this in possibly very naive way:
class Post < ActiveRecord::Base
...
def cell(method_symbol)
PostCell.(self).(method_symbol)
end
end
it works quite well for "not so comlicated" methods, however when I use it on cell method link_to_title which looks like this
class PostCell < Cell::ViewModel
...
def link_to_title
link_to model.title, model
end
end
it fails with
undefined method `[]' for nil:NilClasson line 58 of the gem code https://github.com/trailblazer/cells-rails/blob/master/lib/cell/rails.rb#L58
It seems to be missing some part of the context, but I do not know how to make it happy :(
Metadata
Metadata
Assignees
Labels
No labels