I need a sort of mini cms function in my app, allow a user to alter the
content of the site (nothin too sophisticated). Just want them to be
able to alter “fragments” of content on the pages.
I do it like this and I know it’s not the best way, can someone tell me
a better way (a simple example if possible), I believe I need something
in my model to allow me to stop rpeating myself and stop all the typing
!..
class WelcomeController < ApplicationController
def index
@blog_entry = BlogEntry.most_recent
@content = PageContent.find(:first, :conditions => “title = ‘home’”)
end
def enquiries
@content = PageContent.find(:first, :conditions => “title =
‘enquiries’”)
redirect_to :controller => “enquiries”, :action => “new”
end
def euroblog
@content = PageContent.find(:first, :conditions => “title =
‘euroblog’”)
@articles = BlogEntry.all_blog_entries
end
def people
@content = PageContent.find(:first, :conditions => “title =
‘people’”)
end
def gallery
@content = PageContent.find(:first, :conditions => “title =
‘gallery’”)
@gallery_entries = GalleryItem.all_gallery_entries
end
def courses
@content = PageContent.find(:first, :conditions => “title =
‘courses’”)
@courses = Course.all_courses
end
def accommodation
@content = PageContent.find(:first, :conditions => “title =
‘accommodation’”)
end
def excursions
@content = PageContent.find(:first, :conditions => “title =
‘excursions’”)
end
def bournemouth
@content = PageContent.find(:first, :conditions => “title =
‘bournemouth’”)
end
def prices
@content = PageContent.find(:first, :conditions => “title =
‘prices’”)
@courses = Course.all_courses
end
def agents
@content = PageContent.find(:first, :conditions => “title =
‘agents’”)
end
def find_us
@content = PageContent.find(:first, :conditions => “title =
‘find_us’”)
end
def opening_times
@content = PageContent.find(:first, :conditions => “title =
‘opening_times’”)
end
def visas
@content = PageContent.find(:first, :conditions => “title =
‘visas’”)
end
def terms
@content = PageContent.find(:first, :conditions => “title =
‘terms’”)
end
end