If you're looking for cleaner options, here are a few suggestions:
1) Create a specific layout for each set of css/js requirements and specify the appropriate layout in the action. This method works best if you have multiple actions sharing the same css/js, otherwise it might result in a cluttered layout structure.
2) A slightly more reusable approach is to set a variable like @include_toggles = true
in your action and include "jquery-toggles" only if that variable is true. This way, you can use the same variable in other actions requiring jquery-toggles without having to check against specific action or controller names.
3) If each action has its own unique css/js files not shared with others, consider organizing them inside a directory named after the action. Then, you can include all files from that directory using interpolation to dynamically fetch the necessary files for the current action. For example, for the index action:
<%= javascript_include_tag Dir[Rails.root.join("public/javascripts/views/#{action_name}/*.js")].map { |s| s.sub(Rails.root.join("public/javascripts/").to_s, "") } %>
(The code snippet above was inspired by a previous answer, with the addition of #{action_name}
as an illustration.)
Hopefully, these suggestions offer some clarity. While there may be other alternatives available, these ideas aim to provide simplicity and cleanliness in implementation.