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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
2008/1/22, bingo bob :> 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 !....Using ActionController::Base#action_name in a before_filter can be your friend. -- Jean-François. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jean-François Trân wrote:> 2008/1/22, bingo bob : >> 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 !.... > > Using ActionController::Base#action_name in a before_filter > can be your friend. > > -- Jean-Fran篩s.Ok, can you elaborate? Sounds interesting. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2008/1/22, bingo bob <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Using ActionController::Base#action_name in a before_filter > > can be your friend. > > > > -- Jean-François. > > Ok, can you elaborate? > > Sounds interesting.class WelcomeController < ApplicationController before_filter :find_content, :except => [ :index ] # ... def agents end # ... private def find_content @content = PageContent.find_first_by_title(action_name) end end Not tested, but you get the idea. -- Jean-François. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
you might also want to have a look at comatose - it doesn''t do exactly what you are asking for out of the box, but it is a nice plugin cms to add to a site. *http://code.google.com/p/comatose-plugin/* On Jan 22, 2008 8:09 AM, Jean-François Trân <jftran-HujFcYLiWL6M4zKIHC2jIg@public.gmane.org> wrote:> > 2008/1/22, bingo bob <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: > > > > Using ActionController::Base#action_name in a before_filter > > > can be your friend. > > > > > > -- Jean-François. > > > > Ok, can you elaborate? > > > > Sounds interesting. > > class WelcomeController < ApplicationController > before_filter :find_content, :except => [ :index ] > > # ... > > def agents > end > > # ... > > private > def find_content > @content = PageContent.find_first_by_title(action_name) > end > end > > Not tested, but you get the idea. > > > -- Jean-François. > > > >-- Andrew Kuklewicz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jean francois idea seems perfect..it wont work for me though!
can someone have a look at the code...
the error i get it...
undefined method `find_first_by_title'' for #<Class:0x2ad6518>
confused....BB
--------
class WelcomeController < ApplicationController
before_filter :find_content, :except => [ :index ]
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
private
def find_content
@content = PageContent.find_first_by_title(action_name)
# @content = PageContent.find(:first, :conditions => "title =
''terms''")
end
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
anyone help, i think it should work, clearly my syntax is wrong? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
2008/1/22, bingo bob <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> jean francois idea seems perfect..it wont work for me though! > > can someone have a look at the code... > > the error i get it... > > undefined method `find_first_by_title'' for #<Class:0x2ad6518>oops, it should be @content = PageContent.find_by_title(action_name) -- Jean-François. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---