What follows are the things I had to do to update the Reddit on Rails project to Rails 5.
rails new reddit_on_rails --database=postgresql
Comment in BCrypt
.
Add:
gem 'jquery-rails'
Add to :development, :test
:
gem 'shoulda-matchers', git: 'https://github.com/thoughtbot/shoulda-matchers.git', branch: 'rails-5'
gem 'rails-controller-testing'
gem 'rspec-rails', '~> 3.5'
gem 'factory-girl-rails'
Add to :development
:
gem 'pry-rails'
gem 'byebug'
gem 'better_errors'
gem 'binding_of_caller'
Run bundle install
.
Run rails g rspec:install
.
Add shoulda_matchers
configuration. In the rails_helper.rb
:
require 'shoulda/matchers'
RSpec.configure do |config|
#...
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
#...
end
Run rails db:create
. The create the following:
Run rails g model User name:string:index password_digest:string session_token:string:index
.
Edit the resulting migration, then run rails db:migrate
.
Paste the contents of the old project's user model specs into that of the new project.
Paste the contents of the old project's user model into that of the new project.
Most tests pass. Create the other models that are required to get them all to pass.
Run rails g model Sub moderator_id:integer:index name:string:index description:text
.
Edit the resulting migration, then run rails db:migrate
.
Paste the contents of the old project's sub model specs into that of the new project.
Paste the contents of the old project's sub model into that of the new project.
Most tests pass. Create the other models that are required to get them all to pass.
Run rails g model Post title:string url:string content:text user_id:integer:index
.
Edit the resulting migration, then run rails db:migrate
.
Paste the contents of the old project's post model specs into that of the new project.
Paste the contents of the old project's post model into that of the new project.
Most tests pass. Create the other models that are required to get them all to pass.
Run rails g model PostSub post_id:integer:index sub_id:integer:index
.
Edit the resulting migration, then run rails db:migrate
.
Paste the contents of the old project's post sub model specs into that of the new project.
Paste the contents of the old project's post sub model into that of the new project.
Most tests pass. Create the other models that are required to get them all to pass.
Run rails g model Comment body:text parent_comment_id:integer:index post_id:integer:index user_id:integer:index
.
Edit the resulting migration, then run rails db:migrate
.
Paste the contents of the old project's comment model specs into that of the new project.
Paste the contents of the old project's comment model into that of the new project.
Most tests pass. Create the other models that are required to get them all to pass.
Run rails g model UserVote user_id:integer:index value:integer
.
Edit the resulting migration, then run rails db:migrate
.
Paste the contents of the old project's user vote model specs into that of the new project.
Paste the contents of the old project's user vote model into that of the new project.
Most tests pass. Create the other models that are required to get them all to pass.
I then copied all of the routes in.
Copy the controller content.
Copy the controller tests.
Make sure that the params are properly nested in the controller tests.
I then copied and pasted all of the non-layout views folders into the new project.
Rails initializes with a git folder. Remove it.
Zip the project up.
After all of this, I made sure that the Readme was good to go.
@niartenyam Whoops!