简体   繁体   English

轨道上的红宝石不会生成模型

[英]ruby on rails will not generate model

I am trying to generate a model in rails. 我正在尝试在Rails中生成模型。 I write: 我写:

rails generate model Post content:text rails生成模型发表内容:文字

And it won't do anything. 而且它什么也不会做。 I don't even get an error message. 我什至没有收到错误消息。 Only the warning about using fiddle but I don't think that should stop me. 只有关于使用小提琴的警告,但我认为这不会阻止我。 I am using windows and Ruby version 2.0 . 我正在使用Windows和Ruby 2.0版。 I know it's suppose to say create etc but it literally says nothing. 我知道应该说create等,但实际上什么也没说。 Please help. 请帮忙。 I can't even move on 我什至不能继续前进

First run 首轮

spring stop

Now, try to generate model 现在,尝试生成模型

Ruby use rails to create some steps. Ruby使用rails创建一些步骤。

For creating is: 对于创建是:

rails g model post

Or try: 或尝试:

rails generate model post

However check if you installed ruby correctly use this is your command prompt: 但是,请检查命令是否正确安装了ruby,这是您的命令提示符:

ruby - v     

And then check if rails was installed in your command prompt: 然后检查命令提示符中是否安装了rails:

rails -v

Have you tried generating your rails app first? 您是否尝试过先生成Rails应用程序?

rails new myApp
cd myApp/
rails generate model Post content:text

This will now generate the desired code. 现在将生成所需的代码。 You must be inside a rails directory to run the appropriate commands. 您必须在rails目录中,才能运行适当的命令。

If you "rails new myApp" command does not generate output and a folder, then you do not have rails installed. 如果“ rails new myApp”命令不生成输出和文件夹,则您没有安装Rails。

So that works when i create my app using 所以当我使用创建应用程序时可以使用

rails new myapp

however when i went to a meetup and they were helping me get started they told my to start an new application using 但是,当我参加聚会时,他们在帮助我入门,他们告诉我使用

rails new myapp -O - T

the addition of the -O -T was probably what was holding me back from creating the model because once i removed it i was able to generate a model. -O -​​T的添加可能使我无法创建模型,因为一旦删除它,我便可以生成模型。 Does anyone have any idea what that -O -T stands for and its implication when creating an app? 有谁知道-O -T代表什么以及在创建应用程序时的含义? but anyway besides that my model is now working:) 但无论如何,除了我的模型现在正在工作:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM