Loading ...
Sorry, an error occurred while loading the content.

Re: [ruby-india] HOW TO USE A SINGLE CONTROLLER FOR MORE THAN ONE MODEL

Expand Messages
  • Shashank Date
    Hi Shashi ... ... I do not know of a way to generate the same Admin Controller for another model. But you can always have two different
    Message 1 of 2 , Sep 26, 2005
    • 0 Attachment
      Hi Shashi

      --- dshashidharreddy <dshashidharreddy@...> wrote:

      <snip>

      > As per my knowledge ROR allows to create scaffold with the below
      > command
      >
      > c:\>ruby script/generate scaffold Employee Admin
      >
      > here Employee as Model and Admin as controller.
      >
      > Now my doubt is how can I use the same Admin Controller for Salary
      > model?

      <snip>

      I do not know of a way to generate "the same Admin Controller" for another model.
      But you can always have two different controllers (and then manually merge them somehow):

      c:\rails_app>ruby script/generate scaffold Employee 'admin/employee'
      dependency model
      exists app/models/
      exists test/unit/
      exists test/fixtures/
      ....
      ....

      and then

      c:\rails_app>ruby script/generate scaffold Salary 'admin/salary'
      dependency model
      exists app/models/
      exists test/unit/
      exists test/fixtures/
      ....
      ....

      create app/views/layouts/salary.rhtml
      overwrite public/stylesheets/scaffold.css? [Ynaq] y
      force public/stylesheets/scaffold.css
      ....

      Note that you have to be careful with it trying to overwrite scaffold.css if you have modified it
      in any way. Doing it this way will allow you to do the following for the Employee admin:

      http://localhost:3000/admin/employee/new

      and, this for the Salary admin:

      http://localhost:3000/admin/salary/new

      I am not a Rails guru, so I am pitching this over to the Rails ML in case someone has a better
      solution.

      > Shashi

      HTH,
      -- shanko




      __________________________________
      Yahoo! Mail - PC Magazine Editors' Choice 2005
      http://mail.yahoo.com
    Your message has been successfully submitted and would be delivered to recipients shortly.