Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/assets/javascripts/friends.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/friends.scss
Original file line number Diff line number Diff line change
@@ -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/
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
class ApplicationController < ActionController::Base
class ApplicationController < ActionController::API
end
9 changes: 9 additions & 0 deletions app/controllers/friends_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class FriendsController < ApplicationController
def get
@id = params[:id]

end

def add
end
end
6 changes: 6 additions & 0 deletions app/controllers/get_friends.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class GetFriendsController < ApplicationController
def getfriends
puts "Honey, I'm home!"
@greeting = "Get Friends action says: Hello world!"
end
end
4 changes: 2 additions & 2 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions app/helpers/friends_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module FriendsHelper
end
2 changes: 2 additions & 0 deletions app/models/friend.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Friend < ApplicationRecord
end
2 changes: 2 additions & 0 deletions app/views/friends/add.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Friends#add</h1>
<p>Find me in app/views/friends/add.html.erb</p>
3 changes: 3 additions & 0 deletions app/views/friends/get.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>Friends#get</h1>
<h1><%= @param_a %></h1>
<p>Find me in app/views/friends/get.html.erb</p>
1 change: 1 addition & 0 deletions app/views/pages/getfriends.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= @greeting %>
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions db/migrate/20200605183614_create_friends.rb
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions test/controllers/friends_controller_test.rb
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions test/fixtures/friends.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions test/models/friend_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class FriendTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end