簡體   English   中英

導軌 g model 或導軌 g 腳手架不會創建 model

[英]rails g model or rails g scaffold doesn't create model

我開始使用 Ruby 並使用簡單的應用程序來獲得基礎知識。

我使用 --skip-active-record 標志創建應用程序。 現在我需要一個 model 和兩個rails g model Articles title:string text:string or rails g scaffold Articles title:string text:string

環境:

  • 贏 7 x64
  • ruby 2.7.1p83(2020-03-31 修訂版 a0c7c23c9c)[x64-mingw32]
  • 導軌 6.0.3.2

寶石文件

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.2'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'ruby_cowsay'

gem 'jbuilder'

gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"

gem 'activerecord', '~> 6.0', '>= 6.0.3.2'

您對問題出在哪里有想法嗎?

我理解你已經使用了--skip-active-record ,你是在通知應用程序你不會使用模型。 因此,它實際上跳過了 model 文件夾。 我不確定您是否 100% 確定您的動機。 但如果您想在這種情況下啟用它,您可以執行以下操作。

1. Add database related gem in Gemfile ex: gem 'mysql2'
2. In config/application.rb uncomment the line require "active_record/railtie"
3. Add database.yml

    

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM