Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7617547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:10:40+00:00 2026-05-31T03:10:40+00:00

If I want to change the default controller template created by scaffold in Rails

  • 0

If I want to change the default controller template created by scaffold in Rails it’s dead easy – after Googling around I found I can just put a controller.rb file in lib/templates/rails/controller for the generator to pick up on instead of the default.

I cannot find any explanation of where I can do the same for a model file. I don’t want to build a separate generator, I just want:

> rails generate model foo 

to create foo.rb model file based on a model.rb template I make.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:10:41+00:00Added an answer on May 31, 2026 at 3:10 am

    Not sure if this is a great idea but you can find the generator code here: https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/model/model_generator.rb

    module Rails
      module Generators
        class ModelGenerator < NamedBase #metagenerator
          argument :attributes, :type => :array, :default => [], :banner => "field[:type][:index] field[:type][:index]"
          hook_for :orm, :required => true
        end
      end
    end
    

    According to this post though you should be able to put a template in lib/templates/rails/model though you may need to specify where it is located via a rake task according to this

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to change the default arguments passed to a Ruby function. For example,
Our designers want to change the color of the default UITabBar. Of course they
I want to modify / change the way the floatformat works. By default it
I want change the default code generator of ASP.NET MVC and use Hanselman Way
In my controller I want to specify a different View than default. Like this
I want to be able to change the default mapping of actions with RESTful
I want to change the default route on my application to use an optional
i want to change the default route in RoR to what i want: consider
I want to redirect my controller methods, so that I can submit a form
I want to change the Text of the browse button in the FileUpload Control

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.