Scaffolding with namespace

Hi,

is there a way to scaffold with namespace?
I’d like to generate a Posts model with namespace admin. But using
script/generate scaffold admin/post title:string
the migration would generate a table “admin_posts”.
So I did now
script/generate scaffold post title:string
moved the controller, views manually to admin/… and had to change each
link manually from (e.g.)
redirect_to @post
to
redirect_to(admin_post_path(@post))

I think there has to be a simpler way.

Tia,
Martin

Martin wrote:

is there a way to scaffold with namespace?

Don’t lean on scaffolds too much. Rails coding is generally not about
the
scaffolds.

So I did now
script/generate scaffold post title:string
moved the controller, views manually to admin/… and had to change each
link manually from (e.g.)
redirect_to @post
to
redirect_to(admin_post_path(@post))

A generator produced rubber-stamp code for you to upgrade. The rest is
up to
you.

Next, scaffolds are fun for people who understand databases, which means
they might not be the best solution for your customers. They might need
pages which lead them thru their workflow, regardless which models these
cross.


Phlip

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