announcement-test/app/controllers/announcements_controller.rb

46 lines
916 B
Ruby
Raw Normal View History

2014-04-01 07:12:43 +00:00
class AnnouncementsController < ApplicationController
def index
announcements = Bulletin.all
2014-04-02 06:44:36 +00:00
anns = announcements.collect do |a|
2014-04-01 07:12:43 +00:00
{
"title" => a.title,
"body" => a.body,
2014-04-02 06:44:36 +00:00
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
"more" => "More",
2014-04-01 07:12:43 +00:00
}
end
2014-04-02 06:44:36 +00:00
{
"data" => anns
}
2014-04-01 07:12:43 +00:00
end
def widget
announcements = Bulletin.all
2014-04-02 06:44:36 +00:00
anns = announcements.collect do |a|
2014-04-01 07:12:43 +00:00
{
"title" => a.title,
"subtitle" => a.body,
2014-04-02 06:44:36 +00:00
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
2014-04-01 07:12:43 +00:00
"more" => "More",
}
end
2014-04-02 06:44:36 +00:00
{
"extras" => {"link_to_index" => "index","name" => "Harry"},
"data" => anns
}
2014-04-01 07:12:43 +00:00
end
def show
params = OrbitHelper.get_params
announcement = Bulletin.find_by_param(params[:uid])
{
"title" => announcement.title,
"body" => announcement.body
}
2014-04-02 06:44:36 +00:00
end
2014-04-01 07:12:43 +00:00
end