Open xfyuan opened 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
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
)
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.)