how to make semantic form visible only to certain roles in ruby?

35 Views Asked by At

There are two forms in a custom page, i want to add certain roles to each form to be visible, eg, SomeForm 1 should be shown if the current user has role profile_manager and SomeForm 2 should be shown if the current user has role poc_manager role. how should i do this? please help

<div>
    <%= semantic_form_for 'SomeForm 1', url: url, method: :post,
      builder: ActiveAdmin::FormBuilder do |f| %>
        <%= f.inputs 'Filter form' do %>
      
            <%= f.input :action_name, label: 'Action name',:as => :select, :collection =["Filter"]%>
            <%= f.input :profile_id, label: 'Profile id'%>
            <%= f.actions do %>
                <%= button_to 'Submit'%>
            <% end %>
        <% end %>
    <% end %>

    <%= semantic_form_for 'SomeForm 2', url: url, method: :post,
      builder: ActiveAdmin::FormBuilder do |f| %>

      <%= f.inputs 'Filter Form' do %>
        <%= f.input :action_name, label: 'Action name',:as => :select, :collection => ["Filter"] %>
        <%= f.input :poc_profile_id, label: 'POC Profile id'%>
        
        <%= f.actions do %>
            <%= button_to 'Submit'%>
        <% end %>
      <% end %>
    <% end %>
</div>
0

There are 0 best solutions below