Skip to content
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

Fix inertia routes helper #195

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

skryukov
Copy link
Contributor

This PR improves inertia routes helper by adding support for:

  • namespaced and scoped routes
namespace :settings do
  inertia 'appearance' => 'settings/appearance'
end

scope :settings do
  inertia 'appearance' => 'settings/appearance'
end
  • symbol notation for route paths
inertia settings: 'settings'
  • shorthand syntax with default component:
inertia :settings # => pages/settings.jsx

namespace :settings do
  inertia :appearance # => pages/settings/appearance.jsx
end

Copy link
Collaborator

@BrandonShar BrandonShar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you! Just a quick question to make sure I understand the code.

get(route => 'inertia_rails/static#static', defaults: { component: component })
def extract_route_and_component(args)
if args.is_a?(Hash)
args.first
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now matter how much Ruby I write, I'm still regularly surprised by syntax 😄

@scope = @scope.new(module: nil)
get(route, to: 'inertia_rails/static#static', defaults: { component: component })
ensure
@scope = @scope.parent
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what this is doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overrides defaults coming from the namespace helper. Btw, I missed the resource helper, will update the PR to support it as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants