-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails Engine support #1945
Comments
@joelhawksley @camertron @Spone @boardfish any thought's on this |
Sounds to me like the solution is well understood here, so we can go ahead with the described change. @tkowalewski, would you like to open a pull request for this? |
@boardfish Yep, I will prepare pull request soon. Thanks |
Work in progress (#1951) |
You can leave the issue open while working on the PR. |
@tkowalewski is their any reason you closed this, because it may still be useful to track the progress of this feature(normally we close the issue once the PR has been merged by adding a closses <issue_num> to the PR description) |
Oh, ok I thought it would be better to have conversations in one place (in the PR) |
Thanks for your work on this @tkowalewski – trying to get this working at the moment (but with |
There's another issue with view_component when it comes to isolated engines - it uses a global configuration. This means that a dummy app can configure Right now this is clearly visible with render monkeypatch, preview settings, test controller settings, and url helpers included in view components by default:
|
Sound familiar @reeganviljoen? (#1987) It sounds like we need to consider moving away from global ViewComponent configuration. @boardfish I know you've done a lot of work on our config architecture, what do you think about all of this? |
@joelhawksley I am just on holiday now I can take a better look at this next week and let you know. |
@joelhawksley I think this is a good idea, but this means we need to make config local to something, so do we make it local to a component, an engine, or anything else? |
@reeganviljoen I'm thinking we make it per-component, with the expectation that folks would set config on ApplicationComponent. |
@jfi In this pull request (#1951) I am trying to focus on support for generating components in rails engine. |
@joelhawksley Apologies, this thread fell by the wayside! I'd like to take a deeper look into this – off the top of my head, the first thing that comes to mind is how Rails engines get generated with their own internal I'd want to make sure that that's also compatible with engines, but it's harder to make assumptions about where |
I want to use view components in Rails Engine, but component generator produces component file without module (engine) name.
We can fix this manually always after component generation :|, but there should be support for
module_namespacing
like in templates in Rails.How to reproduce
Create new Rails Engine
Add
view_component
as dependency indummy.gemspec
and fix
dummy.gemspec
specs by addinghomepage
,summary
...Install gems
Require view component library in
lib/dummy/engine.rb
by adding at the topGenerate view component
And generated component (
app/components/dummy/example_component.rb
) looks likeExpected behaviour
ViewComponent should generate components within Rails Engine module like all other resources generated for Rails Engine.
Expected component
The fix
To generate component within Rails Engine module we should use
module_namespacing
method in templates.For example
lib/rails/generators/component/templates/component.rb.tt
should looks like:The text was updated successfully, but these errors were encountered: