1

I am getting started with Ruby and working on simple app to get the basics.

I create the app with --skip-active-record flag. Now I need a model and neither rails g model Articles title:string text:string or rails g scaffold Articles title:string text:string doesn't generate the model (note: scaffold command creates everything except model).

Environment:

  • Win 7 x64
  • ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c)[x64-mingw32]
  • Rails 6.0.3.2

Gemfile

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'

Do you have a thoughts on where is the issue?

Joe Dow
  • 323
  • 2
  • 7
  • It's not possible for us to help you if you don't tell us what the error is :) Can you paste your terminal output after trying your commands please – Mark Jul 30 '20 at 09:43
  • It is empty, there is no error. First command executes and prints (and creates) nothing. Scaffold command creates (and prints in console) everything what is expected except model – Joe Dow Jul 30 '20 at 10:09
  • If after looking through the question you do not see any issue I would like to ask about favor to follow my steps and create a model. If model is created please share your gemfile and others environment conditions – Joe Dow Jul 30 '20 at 10:11
  • 1
    A bit weird: your `rails g model` normally creates the migration to create the table, a model always derives from `ActiveRecord::Base`, since you are not using active record, how is rails to know how you want to store/create the columns and model? What is your expectation here? – nathanvda Jul 30 '20 at 16:25
  • My intent is to add active record to existing application and I prefer to use sqlite3 as a storage. You might notice activerecord gem in gemfile above. It should answer first question from comment. And my expectations from commands above are to create a model. – Joe Dow Jul 31 '20 at 10:31

1 Answers1

2

what I understand as you have used --skip-active-record by this you are informing the application that you are not going to use models. For that reason it is actually skipping the model folder. I am not sure about your 100% sure about your motive here. but if you want to enable it in that case you can do the following.

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

    
  • Thank you, I used sqlite3 and faced with issue "cannot load such file -- sqlite3/sqlite3_native" from activesupport dependency – Joe Dow Jul 31 '20 at 10:34
  • hi @JoeDow sorry for the late reply. Have you managed to fix it. I am not sure about sqlite3_native issue. you can check the following link I guess this will help you. https://stackoverflow.com/questions/17643897/cannot-load-such-file-sqlite3-sqlite3-native-loaderror-on-ruby-on-rails – Syed Samiuzzaman Aug 01 '20 at 04:50
  • Thank you for follow up. There was some dependecy issue – Joe Dow Aug 08 '20 at 04:24