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 8954603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:20:39+00:00 2026-06-15T14:20:39+00:00

I am writing a Rails 3.2 generator and would like to use Thor::Shell::Basic instance

  • 0

I am writing a Rails 3.2 generator and would like to use Thor::Shell::Basic instance methods (e.g. ask or yes?) like they do in the official Rails guides on Application Templates.

module MyNamespace
  class ScaffoldGenerator < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)

    if yes? "Install MyGem?"
      gem 'my_gem'
    end

    run 'bundle install'
  end
end

This will give me a NoMethodError: undefined method 'yes?' for MyNamespace::ScaffoldGenerator:Class.

I cannot figure out a clean way to make those instance methods available – I am already inheriting from Rails::Generators::Base.

Edit:

Ah, it probably has nothing to do with Thor… I get a warning:

[WARNING] Could not load generator "generators/my_namespace/scaffold/scaffold_generator"

Something is not set up correctly although I used the generator for generating generators…

  • 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-06-15T14:20:39+00:00Added an answer on June 15, 2026 at 2:20 pm

    Oh, yes, it does have to do something with Thor.

    Do not let yourself get confused by the warning. You know that Rails::Generators uses Thor, so walk over to the Thor Wiki and check out how Thor tasks work.

    The rails generator execution will call any method in your generator. So make sure that you organize your stuff into methods:

    module MyNamespace
      class ScaffoldGenerator < Rails::Generators::Base
        source_root File.expand_path('../templates', __FILE__)
    
        def install_my_gem
          if yes? "Install MyGem?"
            gem 'my_gem'
          end
        end
    
        def bundle
          run 'bundle install'
        end
      end
    end
    

    Be sure to put your generator into the right folder structure, e.g. lib/generators/my_namespace/scaffold_generator.rb.

    Thanks for asking your question, dude!

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

Sidebar

Related Questions

I'm writing a non-Rails ruby application (gasp!) and would like to be able to
I am writing a Rails 3 generator, but things get a bit complicated so
I am writing a Ruby CLI (Command Line Interface) program and I would like
I'm writing a Rails app & at the moment I'm making sitemap generator. Everything
I'm writing a rails app that has a model called 'User' and a model
I'm writing a Rails app which has the following jasmine spec: describe buttons, ->
I'm writing a Rails app that needs to store shape data representing the floor
We are writing a Rails application that is using CouchDB as its data store.
I'm currently writing a Rails app, and hit a somewhat strange quirk. I have
I'm writing my first Rails app and I'm confused by a method call that

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.