Select specific fields from Model Instance in rails 2.3 -


i using rails 2.3. in application need selected fields model instance. , code looks like

searches.collect {|s| s.emp_search.find( :select => "id, name")} 

from code getting error message because of find method used in model instance. wants id , name emp_search instance. please guide me how achieve requirement

if result intended like

[   [1, 'search 1'],   [2, 'search 2'],   [3, 'search 3'] ] 

then go along lines of

searches.map |search|    search.emp_search.select([:id, :name]).map {|s| [s.id, s.name]} end 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -