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

Question: how about the frontend folder/file naming convension when using inertia-rails? #122

Open
xfyuan opened this issue Jun 26, 2024 · 3 comments

Comments

@xfyuan
Copy link

xfyuan commented Jun 26, 2024

First, Thanks for your hard work to introduce the great gem to integrated the inertia.js into rails! 👍

There're a few confused questions about the frontend folder/file naming convention by using it:

  • What's the best way to naming the frontend folder? snakecase follow Rails way, or other?
  • What's the best way to naming the frontend file? snakecase follow Rails way, or other?

And there're another question which is met from above points:

could we not to call the render in each controller method(such as #show, #index) expicitly, and inertia-rails can know which frontend file/component should be used through the folder/file/class/method namecast?

If we can, It seems to follow the Rails way perfectly.)

@arni1981
Copy link

The latter is mentioned in the docs https://github.com/inertiajs/inertia-rails?tab=readme-ov-file#rails-component-and-instance-props

class EventsController < ApplicationController
  use_inertia_instance_props

  def index
    @events = Event.all
  end

end

...is the same as ...

class EventsController < ApplicationController
  def index
    render inertia: 'events/index', props: {
      events: Event.all
    }
  end
end

@xfyuan
Copy link
Author

xfyuan commented Jun 27, 2024

The latter is mentioned in the docs https://github.com/inertiajs/inertia-rails?tab=readme-ov-file#rails-component-and-instance-props

class EventsController < ApplicationController
  use_inertia_instance_props

  def index
    @events = Event.all
  end

end

...is the same as ...

class EventsController < ApplicationController
  def index
    render inertia: 'events/index', props: {
      events: Event.all
    }
  end
end

Ahh yes, that's it. Thanks for your so kindly reply.)

And how about the former question? It seems that there're different naming style in the README examples?(such as Event/Index and events/index)

@PedroAugustoRamalhoDuarte
Copy link
Contributor

For now, we don't have a strong convention about that. In my opinion is better to use like Event/Index because is the name of the file in the frontend and they use , in React at least, PascalCase.

Inertia Rails contrib uses PascalCase 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

No branches or pull requests

3 participants