Q:

Rails 4 render action=>new does not go through new action

I have most common in rails code
def new
  @company = Company.new
  @companies = Company.order(:name).pluck(:name, :id)
end

def create
  @company = Company.find(params["company"]["id"]) rescue nil
  unless @company
    render action: 'new'
    return
  end

status = @company.update_attributes(total_licenses: params["company"]["total_licenses"].to_i, assigned_licenses: 0)
if status == true 
    redirect_to users_super_admin_index_path, flash: {notice: "License has been allocated to company."}
else
    render action: 'new'
end
end

but when somthing wrong it should render action new, but it directly render template hence @company remains nil and throws an error 
ActionView::Template::Error (First argument in form cannot contain nil or be empty)
I want to find the permanent and right solution, no hacks please :) . And the reason why i am facing this problem.
In my view - 
<%= form_for @company, url: licenses_path, method: "post" do |f| %>
<%= f.label :id, 'Select Company' %><br/>
<%= f.select :id, @companies, :include_blank => "Select Company", required: true %><br/><br/>

<%= f.label :total_licenses, 'License' %><br/>
<%= f.text_field :total_licenses, required: true%><br/><br/>

<%= f.submit 'Assign'%>
<% end %>

A:

Remember that render(action: ...) does not actually run the method in question, it just renders out the template. You will need to manually trigger the new method to do this.

