From e7ac82f3584b3ff984331ece127672d38d6a120a Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 5 Jun 2020 18:01:47 +0000 Subject: [PATCH 1/3] Created Branch --- app/controllers/pages_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index d61ce90..e0b98c3 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,6 +1,6 @@ class PagesController < ApplicationController def home - puts "Honey, I'm home!" - @greeting = "Home action says: Hello world!" + puts "Honey, I'm home!" + @greeting = "Home action says: Hello world!" end end From 65b8d0541eae9a77fcaebd8cacd609b96af1cbae Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 5 Jun 2020 18:19:21 +0000 Subject: [PATCH 2/3] Added getfriends view --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index 31d26b2..8dcf300 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root to: 'pages#home' +get 'getfriends', to: 'pages#getfriends' end From e5ca8de2d3a96fb4746369aec7e446a85a6d62ae Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 5 Jun 2020 20:25:58 +0000 Subject: [PATCH 3/3] Created the friends Controller and view and the friend model --- app/assets/javascripts/friends.coffee | 3 +++ app/assets/stylesheets/friends.scss | 3 +++ app/controllers/application_controller.rb | 2 +- app/controllers/friends_controller.rb | 9 +++++++++ app/controllers/get_friends.rb | 6 ++++++ app/helpers/friends_helper.rb | 2 ++ app/models/friend.rb | 2 ++ app/views/friends/add.html.erb | 2 ++ app/views/friends/get.html.erb | 3 +++ app/views/pages/getfriends.html.erb | 1 + config/application.rb | 1 + config/routes.rb | 2 ++ db/migrate/20200605183614_create_friends.rb | 10 ++++++++++ db/schema.rb | 22 +++++++++++++++++++++ test/controllers/friends_controller_test.rb | 14 +++++++++++++ test/fixtures/friends.yml | 9 +++++++++ test/models/friend_test.rb | 7 +++++++ 17 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/friends.coffee create mode 100644 app/assets/stylesheets/friends.scss create mode 100644 app/controllers/friends_controller.rb create mode 100644 app/controllers/get_friends.rb create mode 100644 app/helpers/friends_helper.rb create mode 100644 app/models/friend.rb create mode 100644 app/views/friends/add.html.erb create mode 100644 app/views/friends/get.html.erb create mode 100644 app/views/pages/getfriends.html.erb create mode 100644 db/migrate/20200605183614_create_friends.rb create mode 100644 db/schema.rb create mode 100644 test/controllers/friends_controller_test.rb create mode 100644 test/fixtures/friends.yml create mode 100644 test/models/friend_test.rb diff --git a/app/assets/javascripts/friends.coffee b/app/assets/javascripts/friends.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/friends.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/friends.scss b/app/assets/stylesheets/friends.scss new file mode 100644 index 0000000..8b8aa1c --- /dev/null +++ b/app/assets/stylesheets/friends.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the friends controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d1..4ac8823 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,2 @@ -class ApplicationController < ActionController::Base +class ApplicationController < ActionController::API end diff --git a/app/controllers/friends_controller.rb b/app/controllers/friends_controller.rb new file mode 100644 index 0000000..9cea933 --- /dev/null +++ b/app/controllers/friends_controller.rb @@ -0,0 +1,9 @@ +class FriendsController < ApplicationController + def get + @id = params[:id] + + end + + def add + end +end diff --git a/app/controllers/get_friends.rb b/app/controllers/get_friends.rb new file mode 100644 index 0000000..9f1dcc1 --- /dev/null +++ b/app/controllers/get_friends.rb @@ -0,0 +1,6 @@ +class GetFriendsController < ApplicationController + def getfriends + puts "Honey, I'm home!" + @greeting = "Get Friends action says: Hello world!" + end +end diff --git a/app/helpers/friends_helper.rb b/app/helpers/friends_helper.rb new file mode 100644 index 0000000..0b69e9b --- /dev/null +++ b/app/helpers/friends_helper.rb @@ -0,0 +1,2 @@ +module FriendsHelper +end diff --git a/app/models/friend.rb b/app/models/friend.rb new file mode 100644 index 0000000..863a36a --- /dev/null +++ b/app/models/friend.rb @@ -0,0 +1,2 @@ +class Friend < ApplicationRecord +end diff --git a/app/views/friends/add.html.erb b/app/views/friends/add.html.erb new file mode 100644 index 0000000..1b63867 --- /dev/null +++ b/app/views/friends/add.html.erb @@ -0,0 +1,2 @@ +

Friends#add

+

Find me in app/views/friends/add.html.erb

diff --git a/app/views/friends/get.html.erb b/app/views/friends/get.html.erb new file mode 100644 index 0000000..e0095ba --- /dev/null +++ b/app/views/friends/get.html.erb @@ -0,0 +1,3 @@ +

Friends#get

+

<%= @param_a %>

+

Find me in app/views/friends/get.html.erb

diff --git a/app/views/pages/getfriends.html.erb b/app/views/pages/getfriends.html.erb new file mode 100644 index 0000000..4751b53 --- /dev/null +++ b/app/views/pages/getfriends.html.erb @@ -0,0 +1 @@ +<%= @greeting %> diff --git a/config/application.rb b/config/application.rb index 6dbb836..ead3255 100644 --- a/config/application.rb +++ b/config/application.rb @@ -10,6 +10,7 @@ module KeepInTouch class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.2 + config.api_only = true # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers diff --git a/config/routes.rb b/config/routes.rb index 8dcf300..046a51e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Rails.application.routes.draw do + get 'friends/get' + get 'friends/add' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root to: 'pages#home' get 'getfriends', to: 'pages#getfriends' diff --git a/db/migrate/20200605183614_create_friends.rb b/db/migrate/20200605183614_create_friends.rb new file mode 100644 index 0000000..de615fb --- /dev/null +++ b/db/migrate/20200605183614_create_friends.rb @@ -0,0 +1,10 @@ +class CreateFriends < ActiveRecord::Migration[5.2] + def change + create_table :friends, :id => false do |t| + t.string :id + t.string :name + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..ed74efe --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,22 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_06_05_183614) do + + create_table "friends", id: false, force: :cascade do |t| + t.string "id" + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end diff --git a/test/controllers/friends_controller_test.rb b/test/controllers/friends_controller_test.rb new file mode 100644 index 0000000..eab1afc --- /dev/null +++ b/test/controllers/friends_controller_test.rb @@ -0,0 +1,14 @@ +require 'test_helper' + +class FriendsControllerTest < ActionDispatch::IntegrationTest + test "should get get" do + get friends_get_url + assert_response :success + end + + test "should get add" do + get friends_add_url + assert_response :success + end + +end diff --git a/test/fixtures/friends.yml b/test/fixtures/friends.yml new file mode 100644 index 0000000..6901b2d --- /dev/null +++ b/test/fixtures/friends.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + id: MyString + name: MyString + +two: + id: MyString + name: MyString diff --git a/test/models/friend_test.rb b/test/models/friend_test.rb new file mode 100644 index 0000000..599defa --- /dev/null +++ b/test/models/friend_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class FriendTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end