Open hksk opened 6 months ago
I'm not familiar with view variants. Is this a Rails feature we're not supporting? If so, could you link to the docs so we can plan out how to support it?
I'm not familiar with view variants. Is this a Rails feature we're not supporting? If so, could you link to the docs so we can plan out how to support it?
https://guides.rubyonrails.org/layouts_and_rendering.html#the-variants-option
@Thrizian
I didn’t know about variant
—this was really helpful to learn!
@hksk I tried it out briefly, and it worked without needing any additional modifications. Here’s an example of how it’s used:
touch app/views/admin/courses/show.html+student.erb
module Admin
class CoursesController < Admin::ApplicationController
before_action :with_variant, only: %i[show]
private def with_variant
if SOME_CONDITION
request.variant = :student
end
end
so I implemented something like this in my generated controller
I guess we can add some like