Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Possible Naming Conflict Between Model and Component #3

@hermiti

Description

@hermiti

While creating a component using

rails g reactrb:component Schedule::Index

If a model exist that matches "Schedule" is used within the component. It will not work:

module Components
  module Schedule
    class Index < React::Component::Base

      before_mount do
        @schedules = Schedule.all
      end

      def render
        ul do
          @schedules.each do |schedule|
            li { schedule.title }
          end
        end
      end

    end
  end
end

What happens is that the Schedule.all tries to use the Component method instead of the reactiverecord model.

index:260 Exception raised while rendering #<Components::Schedule::Index:0x2f6>

    at Opal.defs.TMP_1 [as $new] (<eval>:24540:15)
    at module_constructor.ːmethod_missing (<eval>:23097:54)
    at module_constructor.method_missing_stub [as $all] (<eval>:20693:35)
    at $Index.$a.$$p.TMP_1 (<eval>:85402:56)
    at $Index.ːinstance_exec (<eval>:23026:24)
    at ːrun_callback.$b.$$p.TMP_2 (<eval>:61709:88)
    at Opal.yield1 (<eval>:20885:14)
    at Array.ːeach (<eval>:30895:26)
    at $Index.ːrun_callback (<eval>:61712:64)
    at ːcomponent_will_mount.$a.$$p.TMP_8 (<eval>:63038:23)

I think that documentation may be sufficient to resolve this issue in the future or perhaps an error thrown during generating the original component if a model already exists with the same name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions