我是一個新手,我需要執行一些sql查詢並將其輸出到視圖。在我的控制,我用像「@prob = ActiveRecord::Base.connection.execute("...")
,然後只需在視圖中顯示的@prob,但在視圖輸出保持未來的兩倍0結果列名的結果。ActiveRecord :: Base.connection.execute重複sql輸出
SQL查詢是
@cprob = ActiveRecord::Base.connection.execute("SELECT DISTINCT cause FROM pages LIMIT 2")
和我的應用環境是
Ruby version 1.8.7 (i386-mingw32)
RubyGems version 1.3.6
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Application root C:/Users/Prateek/BitNami RubyStack projects/noc
Environment development
Database adapter sqlite3
Database schema version 20100616055513
更新: - 我發現對於ActiveRecord的:: Base.connection.execute的oputput實際上是含有像散列數組{:0 => QueryResult中:COLUMNNAME => QueryResult中}
讓我怎麼得到的只是從這個
當你在SQlserver上直接運行它時,「SELECT DISTINCT cause FROM pages LIMIT 2」的輸出是什麼? – 2010-07-05 08:55:33