I am new to rails. I am having difficulty in understanding template inheritance. Earlier I have worked in django and seen template inheritence there. There I saw child is told about parent using “extends” command. Can anyone explain how it works here. I have gone through guidelines of ruby but it was not clear.
Thanks
It’s quite simple to do in Rails.
You simply tell the template you are currently rendering to render another template.
For example
layouts/application.html.erbcontains something like this:The important part is the
render :templatepart that then delegates this template to also render thelayouts/main_application.html.erbthat in my case looks something like this:What I am doing here is having a main template that does not contain the navigation (for things like login etc) and the application.html.erb adds that navigation to the
:navcontent placeholder.