New to Rails here, so excuse me if this is simple. I’m having a hard time finding out the answer, which I want to know before I dive in too deep.
The app I’m aiming to build will not really have a differentiation between the ‘show’ view and the ‘edit’ view. For the most part, I would have listings of entries (index view) where you would just click straight through to the edit view. No ‘show’ view is necessary.
It would be like this for the majority of the app. There would still be some sections that would require ‘show’ views, though.
Is it possible to set up a routing structure like this?
If a show view isn’t necessary, you can simply tell the resource route in
routes.rbto not include it, like:If you want to use the same view for both edit and show, in your
showaction, for example, you can do something like:This will use the
edit.html.erbfile when the show action is hit, although in my opinion your best option is to pick a view you plan to use and omit the other in yourroutes.rb.If you simply want to share a lot of view code between the two views, but still differentiate them, just make use of Partials for the shared code.