mCY
mCY

Reputation: 2821

rails activerecord column query

I am new to Ruby on Rails.

I get a simple table whose name is Loadtest.

The table have two attributes which are: testname, exectime.

The table may looks like this :

\-------------------------

testname | exectime |

test A | xx-xx-xx |

test B | xx-xx-xx |

\-------------------------- 

I want to get all the entries under testname, such as ["test A", "test B"]. How could I achieve this?

I could use Loadtest.find(:all) to get all the entries in the table and write some codes to form the testname array. But is there any direct method like Loadtest.column[:testname]?

Thanks for your time!

Upvotes: 1

Views: 67

Answers (1)

xdazz
xdazz

Reputation: 160833

Yes, there is pluck method.

Loadtest.pluck(:testname)

Upvotes: 1

Related Questions