title: Making jeditable inline edit working with Rails select
body: <p>I'm trying to use the jquery jeditable inline editing functionality with Rails. Most of the examples in the documentation (http://www.appelsiini.net/projects/jeditable) are for PHP and hence looking for some help with Rails. This is how PHP does inline editing for using a select dropdown:</p>
  
  <pre><code>&lt;?php
   $array['E'] =  'Letter E'; 
   $array['F'] =  'Letter F'; 
   $array['G'] =  'Letter G'; 
   $array['selected'] =  'F';
   ?&gt;
  
   $('.editable').editable('http://www.example.com/save.php', { 
       data   : '&lt;?php print  json_encode($array); ?&gt;',
       type   : 'select',
       submit : 'OK'
   });
  </code></pre>
  
  <p>What I'm not able to achieve is how to get data from my countries model to fill the select menu (list of countries). The documentation says to json encode my data.</p>
  
  <p>here's my Model which I want to display in the select menu.</p>
  
  <pre><code>create_table "countries", :force =&gt; true do |t|
   t.string   "code",       :limit =&gt; 2
   t.string   "name"
   t.datetime "created_at"
   t.datetime "updated_at"
  end
  </code></pre>
  
  <p>I want to use the 'name' and 'code' fields as the 'name':'value' pair for the select menu. Did this in my controller:</p>
  
  <pre><code>@countries = Country.find(:all, :select =&gt; "name,code")
  </code></pre>
  
  <p>..the above gives me an array of type Country which i converted into a hash (say x) and then did a x.to_json hoping i would get  what i need. I did come close, got,     "us":"usa", "fr":"france", "gr":"greece" which the view had a problem rendering. Basically this hash approach seems lame and was hoping there's a better way to do this.</p>