announcement-test/app/controllers/announcements_controller.rb

46 lines
1.0 KiB
Ruby

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