From 6b4a1f42a1dfba5e17a971014b47a35018839d9a Mon Sep 17 00:00:00 2001 From: antoshNikolak Date: Wed, 1 Feb 2023 17:06:51 +0000 Subject: [PATCH] made controller --- .idea/CrudPraticeRails.iml | 316 +------------------ Gemfile | 11 + Gemfile.lock | 10 + app/controllers/accounts_controller.rb | 4 + app/helpers/accounts_helper.rb | 2 + app/models/account.rb | 2 + app/views/accounts/index.html.erb | 2 + config/routes.rb | 1 + db/migrate/20230201170612_create_accounts.rb | 15 + test/controllers/accounts_controller_test.rb | 8 + test/fixtures/accounts.yml | 19 ++ test/models/account_test.rb | 7 + 12 files changed, 86 insertions(+), 311 deletions(-) create mode 100644 app/controllers/accounts_controller.rb create mode 100644 app/helpers/accounts_helper.rb create mode 100644 app/models/account.rb create mode 100644 app/views/accounts/index.html.erb create mode 100644 db/migrate/20230201170612_create_accounts.rb create mode 100644 test/controllers/accounts_controller_test.rb create mode 100644 test/fixtures/accounts.yml create mode 100644 test/models/account_test.rb diff --git a/.idea/CrudPraticeRails.iml b/.idea/CrudPraticeRails.iml index 7f13e06..2879c89 100644 --- a/.idea/CrudPraticeRails.iml +++ b/.idea/CrudPraticeRails.iml @@ -26,6 +26,7 @@ + @@ -33,6 +34,7 @@ + @@ -67,7 +69,9 @@ + + @@ -87,317 +91,7 @@ \ No newline at end of file diff --git a/Gemfile b/Gemfile index a007553..0e95a76 100644 --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,17 @@ gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false +#MY OWN ADDITIONS +# --------------------- + +#bulma CSS +gem 'bulma-rails', '~> 0.8.0' + +#makes writing forms easier +gem 'simple_form', '~> 5.1' + +#----------------------- + # Use Sass to process CSS # gem "sassc-rails" diff --git a/Gemfile.lock b/Gemfile.lock index 87b17d3..3871f1b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,6 +72,8 @@ GEM bootsnap (1.16.0) msgpack (~> 1.2) builder (3.2.4) + bulma-rails (0.8.2) + sassc (~> 2.0) capybara (3.38.0) addressable matrix @@ -88,6 +90,7 @@ GEM irb (>= 1.5.0) reline (>= 0.3.1) erubi (1.12.0) + ffi (1.15.5-x64-mingw-ucrt) globalid (1.1.0) activesupport (>= 5.0) i18n (1.12.0) @@ -166,10 +169,15 @@ GEM io-console (~> 0.5) rexml (3.2.5) rubyzip (2.3.2) + sassc (2.4.0) + ffi (~> 1.9) selenium-webdriver (4.8.0) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + simple_form (5.1.0) + actionpack (>= 5.2) + activemodel (>= 5.2) sprockets (4.2.0) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -212,6 +220,7 @@ PLATFORMS DEPENDENCIES bootsnap + bulma-rails (~> 0.8.0) capybara debug importmap-rails @@ -219,6 +228,7 @@ DEPENDENCIES puma (~> 5.0) rails (~> 7.0.4, >= 7.0.4.2) selenium-webdriver + simple_form (~> 5.1) sprockets-rails sqlite3 (~> 1.4) stimulus-rails diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb new file mode 100644 index 0000000..89dbaca --- /dev/null +++ b/app/controllers/accounts_controller.rb @@ -0,0 +1,4 @@ +class AccountsController < ApplicationController + def index + end +end diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb new file mode 100644 index 0000000..17850b4 --- /dev/null +++ b/app/helpers/accounts_helper.rb @@ -0,0 +1,2 @@ +module AccountsHelper +end diff --git a/app/models/account.rb b/app/models/account.rb new file mode 100644 index 0000000..c17a874 --- /dev/null +++ b/app/models/account.rb @@ -0,0 +1,2 @@ +class Account < ApplicationRecord +end diff --git a/app/views/accounts/index.html.erb b/app/views/accounts/index.html.erb new file mode 100644 index 0000000..22137ba --- /dev/null +++ b/app/views/accounts/index.html.erb @@ -0,0 +1,2 @@ +

Accounts#index

+

Find me in app/views/accounts/index.html.erb

diff --git a/config/routes.rb b/config/routes.rb index 262ffd5..210eb05 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do + get 'accounts/index' # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Defines the root path route ("/") diff --git a/db/migrate/20230201170612_create_accounts.rb b/db/migrate/20230201170612_create_accounts.rb new file mode 100644 index 0000000..d98d5de --- /dev/null +++ b/db/migrate/20230201170612_create_accounts.rb @@ -0,0 +1,15 @@ +class CreateAccounts < ActiveRecord::Migration[7.0] + def change + create_table :accounts do |t| + t.string :username + t.string :password + t.string :first_name + t.string :last_name + t.string :location + t.string :email + t.string :phone + + t.timestamps + end + end +end diff --git a/test/controllers/accounts_controller_test.rb b/test/controllers/accounts_controller_test.rb new file mode 100644 index 0000000..d13b6d9 --- /dev/null +++ b/test/controllers/accounts_controller_test.rb @@ -0,0 +1,8 @@ +require "test_helper" + +class AccountsControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get accounts_index_url + assert_response :success + end +end diff --git a/test/fixtures/accounts.yml b/test/fixtures/accounts.yml new file mode 100644 index 0000000..9ea9a7f --- /dev/null +++ b/test/fixtures/accounts.yml @@ -0,0 +1,19 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + username: MyString + password: MyString + first_name: MyString + last_name: MyString + location: MyString + email: MyString + phone: MyString + +two: + username: MyString + password: MyString + first_name: MyString + last_name: MyString + location: MyString + email: MyString + phone: MyString diff --git a/test/models/account_test.rb b/test/models/account_test.rb new file mode 100644 index 0000000..b6de6a1 --- /dev/null +++ b/test/models/account_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class AccountTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end