inertiajs / inertia-rails

The Rails adapter for Inertia.js.
https://inertiajs.com
MIT License
515 stars 43 forks source link

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

Open xfyuan opened 2 months ago

xfyuan commented 2 months ago

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:

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 commented 2 months ago

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 commented 2 months ago

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)