mini cms functionality within an app

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
!....

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.

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.

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 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/

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

anyone help, i think it should work, clearly my syntax is wrong?

oops, it should be @content = PageContent.find_by_title(action_name)

   -- Jean-François.