- rails g scaffold job title:string content:text
gem "active_model_serializers"
生成 app/serializers/job_serializer.rb
內容
class JobSerializer < ActiveModel::Serializer
attributes :id, :title, :content, :image_url
end
- 訪問 http://localhost:3000/jobs
- (記得在 db/seed.rb 先塞點假資料)