announcement-test/app/controllers/announcements_controller.rb

46 lines
916 B
Ruby

class AnnouncementsController < ApplicationController
def index
announcements = Bulletin.all
anns = announcements.collect do |a|
{
"title" => a.title,
"body" => a.body,
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
"more" => "More",
}
end
{
"data" => anns
}
end
def widget
announcements = Bulletin.all
anns = announcements.collect do |a|
{
"title" => a.title,
"subtitle" => a.body,
"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.get_params
announcement = Bulletin.find_by_param(params[:uid])
{
"title" => announcement.title,
"body" => announcement.body
}
end
end