# app/controllers/posts_controller.rb
class PostController < ApplicationController
def my_action
# find all records, kemudian map attribut title ke array
@titles = Post.find(:all, :select => "title").map(&:title)
end
end
Informasi tambahan:
.map(&:title) merupakan shorhand dari .map { |x| x.title }
[referensi]
0 comments:
Post a Comment