title: Drop down list form validation alert in ruby on rails
body: <p>I have drop down list and two radio button in a form.here is the code.i dont know how to set validations in controller.when not selecting value from drop down and one of the radio button,i have to show the warning messages 'please select value from dropdown' and check one radio button filed.how it is possible in ruby on rails while submitting a form. </p>
  
  <pre><code>&lt;%= form_tag :action =&gt; 'show' do %&gt;
      &lt;strong&gt;Select device: &lt;/strong&gt; &lt;%= collection_select(:device, :id, @devices, :id, :name, options ={:prompt =&gt; "-Select a device"}) %&gt;
      &lt;br&gt;&lt;/br&gt;
      &lt;strong&gt;Chose: &lt;/strong&gt;&lt;%=  radio_button_tag :name,:time, false, :onclick =&gt; "this.parentNode.submit();"%&gt;Time
      &lt;%=  radio_button_tag :name,:graph%&gt;Graph
      &lt;% end %&gt; 
  </code></pre>
  
  <p>In device.rb i set the following but not showing any messages.</p>
  
  <pre><code> class Device &lt; ActiveRecord::Base
     attr_accessible :name
     validates_presence_of :name
     has_many :properties
  
     def validate
       if name == 'None'
         errors.add_to_base("You must select a device name")
       end
     end
   end
  </code></pre>