I study Rails with the book "Head First Rails"
steps are:
to create my app with the command "rails new tickets"
run server with "ruby script/server"
"ruby script/generate scaffold ..."
But there is no script folder in the project and I get an error "ruby: No such file or directory -- script/generate (LoadError)"
I've found that I need to use "ruby s" to start the server.
But how can I run script/generate?
Is it a new style of generating folders in the rails project and there is no more script folder? Or did I smth wrong?
I have ruby version 2.4.4 and rails 5.2.1
nowadays it is used rails instead of ruby script/, so try rails server or rails generate scaffold
Related
I am writing a small blog application using Rails. I am using Aptana Studio.
When I try to execute:
ruby script/generate scaffold post title:string body:text
from either Aptana Studio or going to the project folder and executing it from the shell, I get this error:
c:\Ruby200\bin\ruby.exe: No such file or directory -- script/generate (LoadError
)
I think you are meaning to do rails generate?
First create a new Rails app:
rails new random_app
cd random_app
rails generate scaffold post title:string body:text
When you "ruby" something, it looks for a file to execute.
Rails is the framework for abstraction and scaffolding.
See "Why does Ruby "script/generate" return "No such file or directory"?".
Rails 3 is the problem. Since Rails 3, all of the "script/whatever" commands have been replaced with "rails whatever".
So now you want rails generate ... or rails server instead.
I am looking at rails plugins to help me modularize my application. I have some basic questions that I am confused about.
Can a rails plugin have its own DB? My application is very little traffic, for internal use, so I am fine with the idea of separate sqlite DB's for each plugin. When I do a "rails plugin new" even if I use --full, there is no database.yml generated. If I create one and do a rake db:create, no sqlite db is created.
Is there a good tutorial available for creating a rails plugin with rails 3.2? Most I find are older and use the enginex gem which I think is now built into rails.
Can you run your plugin as a standalone app for testing, i.e. using WEBrick? When I run "rails server" in my plugin directory, it just says "Error: Command not recognized".
I guess that's it, I am just confused on how to begin.
Creating Migrations
The Rails Guide "Getting Started with Engines" instructs you to use 'rails g model post' from the root directory for your engine.
Getting Started with Engines
If you do this, it will create the db/migrate folder for you with the migration inside of it.
$ rails g model post
invoke active_record
create db/migrate/20120517184738_create_my_engine_posts.rb
create app/models/my_engine/post.rb
invoke test_unit
create test/unit/my_engine/post_test.rb
create test/fixtures/my_engine/posts.yml
You can also generate migrations directly just the same, just as you do with a Rails app.
$ rails g migration AddMyEngineTable
invoke active_record
create db/migrate/20120517185241_add_my_engine_table.rb
Running Rails Server
The Rails Guide also states to run 'rails s' from test/dummy, not from the root of your engine directory.
I see that from an ASCIICast on the subject which covered Rails 3.1 RC5 that you used to be able to run 'rails s' from the root directory of your engine/gem. This is no longer the case.
From the Rails issue posted on Github three months ago it appears that they needed to keep the scope of the engine separate from the scope of the dummy app.
Issue #4894: Mountable Engines Rails File
In short run from the engine root:
test/dummy/script/rails s
Problem:
The rails UI interface for generating scripts bundle in Textmate is not working.
Description:
In a rails document:"Bundles"> "Ruby on Rails"> "Call Generate Script" and choose "Controller" then type"index" > "index" and submit.A window appears telling me: "Done Generating controller".Yet when I browse through my directories nothing new has been created.
Screenshot:
I take a screenshot of what happens during the generation process:
http://img152.imageshack.us/i/capturedcran20110201003.png/
Versions:
ruby -v: ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
rails -v: Rails 3.0.3
I tried the same with an RVM environment by following this tutorial:
(http://rvm.beginrescueend.com/integration/textmate/)
The result is the same.
Regards,
Guillaume.
You have to slightly modifiy the bundle to make it work with the Rails 3 generate scripts. Have a look at my modifications on GitHub:
https://github.com/dhoelzgen/ruby-on-rails-tmbundle
The error there says that there's "No such file or directory -- script/generate". This leads me to beleive that you're using Rails 3, where the command is now rails generate or rails g for short. Upgrade your Ruby on Rails TextMate bundle (follow the instructions on the GitHub Page) or alternatively run rails g controller [name] from the command line.
I tried the rails site_name command to create a rails application. The command says that the usage is rails new APP_PATH[options]
I tried the rails new site_name command.
I dont get any server file inside my site_name/script folder to run the application.
why is this happening?
Use
$ rails server
to start the server. In general with Rails 3, any command you would have previously run with ./script/... you now run with rails ...
I am learning Ruby on Rails using a book I picked up called "Head First Rails" I am in the first chapter and it tells me to create my CRUD procedures using the following command:
ruby script/generate scaffold ticket name:string seat_id_seq:string address:text price_paid:decimal email_address:string
the error I am getting is:
ruby: No such file or directory -- script/generate (LoadError)
Can someone please explain what I am doing wrong. I am not new to development, I am a professional C# developer trying to learn Ruby on Rails.
Are you running that in your application directory? The scaffold command needs to be executed in your application directory in order to find script/generate.
try simply "./script/generate ..." in your project directory
This question is old, but for anyone who is having problems with "Head First Rails" first edition (which is the only one available at this time), it was written for rails 2. So most of the commands, like script/generate, have been replaced by new ones in Rails 3.
I suggest using "Agile Web Development with Rails" book.