Rest and Scaffold Resource Question

Hello, I had a few questions I was hoping someone could shed some light
on.

I am in the process of converting a small app over to use rest, however
I noticed a few oddities that I was unsure of. Currently my app is just
a small store, and I keep all my controllers in /admin/ for the admin
functions. When moving to rest, I was trying to understand the proper
way to use map.resources. Currently for example I have the products
controller in the /admin/ mapped as follows:

map.resources :products,
:path_prefix => ‘/admin’,
:controller => ‘admin/products’

However, after thinking about this, I could see this being an issue when
it comes to using products with the non-admin controllers (ex. The
actual store), where I would need to map products again. Any solution
to this?

The second question is, I realized that scaffold_resource has a few
bugs, which I believe a patch has been submitted. When using
scaffold_resource ‘admin/Product’ for example, I noticed it creates a
model in app/model/admin/ rather then how the “regular” scaffold creates
it in app/model/. Is this correct? I just want to make sure I am
redoing my app correctly before I go any further; I was keeping all the
models in the models directory not in any subdirectories after that.

Please let me know if I need to clarify anything.

Thank you for you help!

  • John

John B. wrote:

Hello, I had a few questions I was hoping someone could shed some light
on.

I am in the process of converting a small app over to use rest, however
I noticed a few oddities that I was unsure of. Currently my app is just
a small store, and I keep all my controllers in /admin/ for the admin
functions. When moving to rest, I was trying to understand the proper
way to use map.resources. Currently for example I have the products
controller in the /admin/ mapped as follows:

map.resources :products,
:path_prefix => ‘/admin’,
:controller => ‘admin/products’

However, after thinking about this, I could see this being an issue when
it comes to using products with the non-admin controllers (ex. The
actual store), where I would need to map products again. Any solution
to this?

The second question is, I realized that scaffold_resource has a few
bugs, which I believe a patch has been submitted. When using
scaffold_resource ‘admin/Product’ for example, I noticed it creates a
model in app/model/admin/ rather then how the “regular” scaffold creates
it in app/model/. Is this correct? I just want to make sure I am
redoing my app correctly before I go any further; I was keeping all the
models in the models directory not in any subdirectories after that.

Please let me know if I need to clarify anything.

Thank you for you help!

  • John

Can anyone please give some insight, I cant seem to find a concrete
example so that I can correct any mistakes I have make before proceeding
to finish this up.
Thanks

  • John

Hey John,
On Feb 14, 2007, at 5:56 PM, John B. wrote:

However, after thinking about this, I could see this being an
issue when
it comes to using products with the non-admin controllers (ex. The
actual store), where I would need to map products again. Any
solution
to this?
Well unless I’m misunderstanding the problem, you can just map them
twice and both urls will work --once for admin and once for the
regular products

models in the models directory not in any subdirectories after that.
Can’t really help too much here but I tried running scaffold_resource
by giving it a directory/name and I got an error about a missing
layouts directory. Perhaps the scaffolding generator just doesn’t
support specifying a directory? You might have to create some
directories manually if you want it setup that way, but not sure.

Andy

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