Simone D'Amico Simone D'Amico - 1 year ago 42
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