Generate Flash message in rails when no record is available in table
<p>I have created a page in Ruby On Rails 4 in which there are two drop down are present for month and year and at the bottom there is Download button,I want the file to be downloaded only if the data is present for that month and year,else i should get an flash message that record not present.I tried in the following ways.Still its not working.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>def index
    @month = params[:salaryslip_component][:month]
    @year = params[:salaryslip_component][:year]
    @salary_components = SalaryComponent.all
    @salaryslips = Salaryslip.where(month: @month,year: @year)
    if @salaryslips.present? == true
      respond_to do |format|
      format.xml { send_data render_to_string(:index), :filename =&gt; 'mydoc.xml', :type=&gt;"application/xml", :disposition =&gt; 'attachment' }
      flash[:danger] = "Salaryslip  processed"
      end
    else
    flash[:danger] = "Salaryslip not yet processed"
    end
  end</code></pre>
</div>
</div>
</p>

<p>please help.... :)</p>