I have been given the task to convert some static html pages into erb pages, to be used in a Rails project. Since all pages belong to same project, they are having a common "application.html.erb" file. But all Html pages have different class names for <body> tag. and since we have common "application.html.erb" file. How to convert such Html pages with different names for <body> tag , into .erb files?
I would do this with an instance variable, which is expected to be set in the controller.
<body class="<%= @body_class %>">
You can then set this on a per-controller or per-action basis. If there is a "formula" to decide what it is, based on the controller and action, you could do it via a single before_filter defined in ApplicationController.
Asked in February 2016Viewed 2,732 timesVoted 7Answered 2 times