0

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>
nim
  • 1
  • 3
  • You can put `if/else` block in the ERB – max pleaner Jul 23 '20 at 17:19
  • Use the current_user object and check the role using if condition to display form on role basis. Help ref: https://stackoverflow.com/questions/6706035/rails-if-statement-syntax – Deepak Jul 23 '20 at 17:44

0 Answers0