0

I ran into one problem that I cannot solve on my own for a week - I am desperate.

I got a Rails 5.2 project that has a Trailblazer on board. In one place of the application, I catch this error:

TypeError - no implicit conversion of Symbol into Hash:
  app/concepts/post/admin/views/_authors_tab.slim:10:in `block (2 levels) in singleton class'
  app/concepts/post/admin/views/_authors_tab.slim:9:in `block in singleton class'
  app/concepts/post/admin/views/_authors_tab.slim:65534:in `singleton class'
  app/concepts/post/admin/views/_authors_tab.slim:65531:in `__tilt_70096639860360'
  app/concepts/post/admin/views/show.slim:14:in `block in singleton class'
  app/concepts/post/admin/views/show.slim:65534:in `singleton class'
  app/concepts/post/admin/views/show.slim:65531:in `__tilt_70096639860360'
  app/concepts/post/admin/cell.rb:13:in `show'
  app/views/admin/posts/show.slim:3:in `_app_views_admin_posts_show_slim__1322321696587881215_70096664842560'
  app/controllers/application_controller.rb:71:in `apply_time_zone'

Started POST "/__better_errors/51d28299c14c669d/variables" for ::1 at 2018-10-22 15:00:18 +0300

_authors_tab.slim:10 (9 and 10 lines):

- authors.each do |author|
  = concept 'post/author/list_item/cell', author, context: :admin

Below is the code that I specifically cut for the best presentation (the error, of course, was preserved):

class Post::Author::ListItem::Cell < RBlog::Cell
  option_property :context, nil_check: true

  def show
    render
  end
end

This is a file (app/concepts/r_blog/cell/option_property.rb) with a description of an unknown method:

module RBlor::Cell::OptionProperty
  def option_property(name, nil_check: false)
    if nil_check
      define_method(name) do
        raise "Option #{name} cannot be blank" if @options[name].nil?
        @options[name]
      end
    else
      define_method(name) { @options[name] }
    end
    private name
  end
end

As for the file show.slim from the code above - I commented on all its contents, deleted it and even left it intact (with the methods described inPost :: Author :: ListItem :: Cell, but which were deleted, as I wrote above ) - this file does not affect anything. Apparently the error appears before it is processed.

What could be the problem

Colibri
  • 993
  • 11
  • 29

2 Answers2

0

I'm not sure what you trying to do in your first line in the cell

option_property -> that's not a defined method call anywhere in Cells project if I remember correctly.

P.S.: I suggest to head down to the Gitter channel for TRB project, you will get a response there much quicker than anywhere else.

konung
  • 6,908
  • 6
  • 54
  • 79
  • I didn't even think about it. But thanks. I added the code to the text. – Colibri Oct 29 '18 at 20:10
  • I comment on the contents of the option_property method (that is, define_method returns null) - the error is still saved. – Colibri Oct 29 '18 at 21:10
  • Another thing that jumps at me is that you passing `:admin` to `context:` which is a a "special" object within cell, and you are also defining a property/method named ":context" on your cell. I think you have a name conflict there . See this https://github.com/trailblazer/cells/blob/2d33ad03a7c973123ca40be7eb8a85ad9f859550/CHANGES.md#410 – konung Oct 30 '18 at 22:19
  • Here is a more direct link: https://github.com/trailblazer/cells/blob/2d33ad03a7c973123ca40be7eb8a85ad9f859550/CHANGES.md#awesomeness – konung Oct 30 '18 at 22:26
0

The problem is context: :i_am_a_symbol, that option is expecting a Hash and not a symbol!

apotonick
  • 520
  • 2
  • 9