Last active
December 21, 2015 23:01
-
-
Save libbyschuknight/60264d0844aba6b7ca90 to your computer and use it in GitHub Desktop.
Steps to creating a new Rails app - from https://github.com/roa-2015/shopping_cart_example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails new "app_name" --database=postgresql --skip-test-unit | |
$cd "app_name" | |
$ git init | |
$ git add -A | |
$ git commit -m "first commit message" | |
install RSpec Rails - https://github.com/rspec/rspec-rails | |
Add rspec-rails to both the :development and :test groups in the Gemfile: | |
group :development, :test do | |
gem 'rspec-rails', '~> 3.0' | |
end | |
run... | |
$ bundle install | |
Initialise spec/ dir... | |
$ rails generate rspec:install | |
use rspec to run commands... rspec or bundle exec rspec | |
Removing Turbolinks (Rails 4?) | |
http://blog.steveklabnik.com/posts/2013-06-25-removing-turbolinks-from-rails-4 | |
http://blog.flightswithfriends.com/post/53943440505/how-to-disable-turbolinks-in-rails-4 | |
$ rails generate resource Name name:string description:text price:integer | |
(generate model etc -- field:type) | |
$rake db:create | |
$rake db:migrate | |
Add some seed code to db/seeds.rb | |
$ rake db:seed | |
Use if want to check data | |
$ rails console | |
Testing - see other Gist | |
When creating/adding to a controller | |
Is named the same as your model if a resource controller but plural and with Controller at the end. | |
Inherits from ApplicationController | |
Add the first action like index | |
Create a folder in views with the same name as the controller. | |
Crate a file in the new views folder with the same name as the controller action. | |
Add a route to point to the new controller action in the config/routes.rb file. | |
If it is a resource you can uses resources to create RESTful routes. | |
Also add a root URL for the homepage if you haven't done so. | |
rails server / s | |
Run rails s to start up the server and visit the site. | |
Add CSS file to assets/stylesheets/ to add styles to site. | |
As you build up routes you can see them all with rake routes. | |
REMEMBER to run | |
rake db:mirgrate | |
rake db:seed | |
- as required | |
And prepare you test db | |
rake db:test:prepare |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment