I have some columns that contain a 开发者_运维知识库large amount of data (text, etc), and sometimes I am just displaying a summary list of the rows and I don't want to fetch all that data.
Is there an option to exclude certain columns?
I don't believe you can exclude certain columns, but you can have ActiveRecord return only specific columns using the :select
parameter, e.g.
@articles = Article.find( :all, :select => ‘created_at, title, summary’ )
you can find by sql query so you can fetch your required data and its easy
Post.find_by_sql("SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date)
精彩评论