-
Following is a very oddness error message which i consider it useful to mention here, you can reproduce it use following sample app strange_error branch. https://github.com/one-in-ten-thousand/production_line_report/tree/strange_error Basically, i just want to use a component for common purpose, this is source code. as you can see, it just a each loop on records, with, pass the different part into it.
Strange things start happen here, I use it like this in two different page. class Admin::Manufactories::IndexPage < MainLayout
needs manufactories : ManufactoryQuery
def content
mount RecordList,
records: manufactories, # <= passed manufactories Here
show: Show,
edit: Edit,
delete: Delete
end
end class Admin::Manufactories::ShowPage < MainLayout
needs workshops : WorkshopQuery
def content
mount RecordList,
records: workshops, # <= passed workshops Here.
show: ::Admin::Workshops::Show,
edit: ::Admin::Workshops::Edit,
delete: ::Admin::Workshops::Delete
end
end When i try to build on it, i get following error message. error trace, click to open
The really wired things is, The fix is simple, split above components to two, all works fine. class ManufactoryList < BaseComponent
needs records : ManufactoryQuery
needs show : Admin::Manufactories::Show.class
needs edit : Admin::Manufactories::Edit.class
needs delete : Admin::Manufactories::Delete.class class WorkshopList < BaseComponent
needs records : WorkshopQuery
needs show : Admin::Workshops::Show.class
needs edit : Admin::Workshops::Edit.class
needs delete : Admin::Workshops::Delete.class So, any idea? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
That is a strange error. It seems to suggest that you were calling In any case, I think splitting them is a much better option in the end 👍 |
Beta Was this translation helpful? Give feedback.
-
Hi, i am dig deeper this issue again, still could not figure out why this strange issue happen. probably previous description not clear enough, let me reduce it. there is a component like following: class RecordList < BaseComponent
needs records : ManufactoryQuery
needs show123 : Admin::Manufactories::Show.class | Admin::Workshops::Show.class
def render
tbody do
records.each do |record|
tr do
pp! show123
pp! show123.with(record)
text "hello"
end
end
end
end
end Then use it in another page, like following: needs manufactories : ManufactoryQuery
mount RecordList,
records: manufactories,
show123: ::Admin::Manufactories::Show Then i always get compile-time error like following:
But if comment So i try change to ``pp! show123.as(Admin::Manufactories::Show.class).with(record)
Another workaround is, remove the union type in component into: I consider the Thanks. |
Beta Was this translation helpful? Give feedback.
That is a strange error. It seems to suggest that you were calling
Admin::Companies::Create.with(record)
somewhere... Maybe a form?In any case, I think splitting them is a much better option in the end 👍