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/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 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 31d26b2..046a51e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,7 @@ 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' end 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