announcement-test/app/controllers/announcements_controller.rb

46 lines
1006 B
Ruby

class AnnouncementsController < ApplicationController
def index
announcements = Bulletin.order_by(:created_at=>'desc').filter_by_categories
anns = announcements.collect do |a|
{
"title" => a.title,
"body" => a.text,
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
"more" => "More",
}
end
{
"data" => anns
}
end
def widget
announcements = Bulletin.order_by(:created_at=>'desc').filter_by_categories
anns = announcements.collect do |a|
{
"title" => a.title,
"subtitle" => a.text,
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
"more" => "More",
}
end
{
"extras" => {"link_to_index" => "index","name" => "Harry"},
"data" => anns
}
end
def show
params = OrbitHelper.params
announcement = Bulletin.find_by(:uid=>params[:uid])
{
"title" => announcement.title,
"body" => announcement.text
}
end
end