Newbie CMS question

Hi guys,

I’m new to Rails, as a starting project I’m trying to put together a
showcase site for some of my projects (web design, audio production
etc…). I’d like to build a basic CMS so I can quickly add updates,
and also to practice my Rails skills.

I’ve been reading the ‘Agile Web D. with Rails’ book which
is great and I’ve been building off the examples in there. I’m
thinking that the way to go is to have a model for the web stuff
(web_item) and a model for the audio stuff (audio_item) and the
associated databases for each. I then generated an admin controller,
then generated a scaffold for the web_item in the admin controller.

This all works ok and I can add data to the database and see my
changes in the browser. But this is obviously only giving me access
to the web_item model. I can’t think of a way to give me access to
the audio_item model as well, using only the admin controller.

Hope that makes sense, sorry if it’s going to be really obvious.
Basically I want an admin section, which I can then choose whether to
edit the web stuff or the audio stuff, then have an area for each.

Thanks,
Henry

Henry B.: Music Production - Audio Engineering - Web D.

Hi Henry,

Well there are lots of ways to do it.

One is to forget about admin_controller all together. Especially if you
will be the only admin of your site. I think you would be best off
simply having your web_items_controller and your audio_items_controller.
then you have your Create-Update-Read-Distroy actions in them. Then you
can use a before_filter in the controllers to make sure only you can do
anything but read:

before_filter :protect_from_public :except => :index, :list, :show

Then define protect_from_public somewhere (maybe application.rb is a
good start):
def protect_from_public
unless session[:admin_user]
redirect_to( :controller => ‘accounts’, :action => :login) and
return false
end
end

then you would have an account_controller to handle your login and
logout. AWD had some stuff in it that would give you a good head start
with that too.
anyway thats the idea.

Hope that helps.

Henry B. wrote:

Hi guys,

I’m new to Rails, as a starting project I’m trying to put together a
showcase site for some of my projects (web design, audio production
etc…). I’d like to build a basic CMS so I can quickly add updates,
and also to practice my Rails skills.

I’ve been reading the ‘Agile Web D. with Rails’ book which
is great and I’ve been building off the examples in there. I’m
thinking that the way to go is to have a model for the web stuff
(web_item) and a model for the audio stuff (audio_item) and the
associated databases for each. I then generated an admin controller,
then generated a scaffold for the web_item in the admin controller.

This all works ok and I can add data to the database and see my
changes in the browser. But this is obviously only giving me access
to the web_item model. I can’t think of a way to give me access to
the audio_item model as well, using only the admin controller.

Hope that makes sense, sorry if it’s going to be really obvious.
Basically I want an admin section, which I can then choose whether to
edit the web stuff or the audio stuff, then have an area for each.

Thanks,
Henry

Henry B.: Music Production - Audio Engineering - Web D.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs