Can you use persistent method ? to make sure that it is not a new record to be inserted or even uses the new_record method ? which will return true if the record is not saved in your "New record" database. ex ::
<%= f.text_field :department if @user.persisted? %> or <%= f.text_field :department unless @user.new_record? %>
another way is to check the action itself, which also gives you control over the controller, if you visualize a partial view from another view and want to limit it to a specific controller, they are stored in:
params[:controller]
source share