I'm trying to avoid code duplication between Admin forms and Regular User forms for the same resource.
I would like to be able to use one form for both, by doing something like:
<% if current_user.admin? %>
<%= form_for([:admin,@post], :html => {class: "form"}) do |f| %>
<% else %>
<%= form_for @post, html: { class: 'form' } do |f| %>
<% end %>
then include fields that only the admin should see via if statements in the body of the form.
This approach doesn't work, I think because the <% end %> is ending the form.
Is there a way to do this? Does this approach even make sense?
Thanks!