2017-11-27 23:19:31 -05:00
|
|
|
# rails
|
|
|
|
|
2017-11-28 23:01:29 -05:00
|
|
|
> A server-side MVC framework written in Ruby.
|
2024-10-04 21:14:41 +02:00
|
|
|
> Some subcommands such as `generate` have their own usage documentation.
|
2019-06-03 02:06:36 +02:00
|
|
|
> More information: <https://guides.rubyonrails.org/command_line.html>.
|
2017-11-27 23:19:31 -05:00
|
|
|
|
|
|
|
- Create a new rails project:
|
|
|
|
|
2017-11-28 22:54:55 -05:00
|
|
|
`rails new "{{project_name}}"`
|
2017-11-27 23:19:31 -05:00
|
|
|
|
2025-02-06 09:03:00 -08:00
|
|
|
- Generate a scaffold for a model named Post, predefining the attributes title and body:
|
|
|
|
|
|
|
|
`rails generate scaffold Post title:string body:text`
|
|
|
|
|
|
|
|
- Run migrations:
|
|
|
|
|
|
|
|
`rails db:migrate`
|
|
|
|
|
|
|
|
- List all routes:
|
|
|
|
|
|
|
|
`rails routes`
|
|
|
|
|
2017-11-28 22:54:55 -05:00
|
|
|
- Start local server for current project on port 3000:
|
2017-11-27 23:19:31 -05:00
|
|
|
|
|
|
|
`rails server`
|
|
|
|
|
2017-11-28 22:54:55 -05:00
|
|
|
- Start local server for current project on a specified port:
|
2017-11-27 23:19:31 -05:00
|
|
|
|
2017-11-28 22:54:55 -05:00
|
|
|
`rails server -p "{{port}}"`
|
2017-11-27 23:19:31 -05:00
|
|
|
|
2021-05-20 16:13:41 -04:00
|
|
|
- Open console to interact with application from command-line:
|
2017-11-27 23:19:31 -05:00
|
|
|
|
2017-11-27 23:30:14 -05:00
|
|
|
`rails console`
|
2017-11-28 22:54:55 -05:00
|
|
|
|
|
|
|
- Check current version of rails:
|
|
|
|
|
|
|
|
`rails --version`
|