Simone D'Amico Simone D'Amico - 2 years ago 63
Ruby Question

Generate a scaffold controller inside an uppercased namespace

I'm using the apn_on_rails gem, that has few models under a namespace named APN.
What is the correct way to generate a scaffold controller for the APN::Device model and route to it correctly?

Answer Source
  1. You can create it just by hands, manualy.
  2. As far as Ruby uses underscore instead of CamelCase you can try this:

rails g scaffold a_p_n::Device ...

which will generate this model for you:

class APN::Device < ActiveRecord::Base

in app/models/a_p_n/device.rb

and it will generate routes for you:

namespace :a_p_n do 
  resources :devices 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download