-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
view variants support #2578
Comments
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 @hksk 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 |
Oh! I see, it's those! @goosys, when you were looking into this, did you see a way which would make this easier to do? (Like an API administrate could support?) |
Hm, that all said, I think solving this with documentation is fairly reasonable too, if we had a section in the Guides, for example! |
No, the sample code I provided was the simplest approach. I also think that providing guidance in the documentation would be sufficient support. |
Yeah, that makes a lot of sense. I'm quite keen to start documenting "advanced" usage of Administrate. We can do our best in our pitch to avoid straying from Rails defaults, but in practice, I find that I'd rather something akin to a cookbook which helps people solve their problems quicker. Would be able to contribute your sample code and an explanation in a PR? |
@nickcharlton I have added a guid and some samples. Please review! |
This adds a guide and two examples of using Rails' view variant support. Closes thoughtbot#2578 https://guides.rubyonrails.org/layouts_and_rendering.html#the-variants-option
add a view variant, example:
currently in the main controller, cant pass a variant, seems variant: :value not works
so I implemented something like this in my generated controller
I guess we can add some like
The text was updated successfully, but these errors were encountered: