diff --git a/.gitignore b/.gitignore index e69de29..c9cfef5 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,28 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-* + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/ +!/tmp/pids/.keep + +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/.learn b/.learn deleted file mode 100644 index 9092bbf..0000000 --- a/.learn +++ /dev/null @@ -1,6 +0,0 @@ -tags: - - tag1 -languages: - - language1 -resources: 0 -parent_template: git@github.com:learn-co-curriculum/sinatra-basic-forms-lab.git diff --git a/Gemfile b/Gemfile index fd00811..1a1b15d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,17 +1,47 @@ -# A sample Gemfile -source "https://rubygems.org" +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } -# gem "rails" +# Ruby 3.3+ compatibility gems +gem 'bigdecimal' +gem 'fiddle' +gem 'logger' +gem 'mutex_m' +gem 'ostruct' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' +gem 'rails', '~> 6.1.3', '>= 6.1.3.1' +# Use sqlite3 as the database for Active Record (updated for Ruby 3.3 compatibility) +gem 'sqlite3', '~> 1.6.0' +# Use Puma as the app server +gem 'puma', '~> 5.0' +# Asset pipeline gems +gem 'sprockets-rails' +gem 'stimulus-rails' +gem 'turbo-rails' +# nio4r for Ruby 3.3 compatibility +gem 'nio4r', '~> 2.7' +# Use Active Model has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible +gem 'rack-cors' + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug', platforms: %i[mri mingw x64_mingw] + gem 'capybara' + gem 'rspec-rails', '~> 5.0.0' +end + +group :development do + gem 'listen', '~> 3.3' + gem 'rubocop' +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] -gem 'sinatra' - gem 'rake' - gem 'thin' - gem 'shotgun' - gem 'pry' - gem 'require_all' - group :test do - gem 'rspec' - gem 'capybara' - gem 'rack-test' - end \ No newline at end of file + gem 'rspec-json_expectations' + gem 'shoulda-matchers', '~> 4.0' +end diff --git a/Gemfile.lock b/Gemfile.lock index 6072aff..caea9fb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,77 +1,270 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - capybara (2.18.0) + actioncable (6.1.7.10) + actionpack (= 6.1.7.10) + activesupport (= 6.1.7.10) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.7.10) + actionpack (= 6.1.7.10) + activejob (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) + mail (>= 2.7.1) + actionmailer (6.1.7.10) + actionpack (= 6.1.7.10) + actionview (= 6.1.7.10) + activejob (= 6.1.7.10) + activesupport (= 6.1.7.10) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (6.1.7.10) + actionview (= 6.1.7.10) + activesupport (= 6.1.7.10) + rack (~> 2.0, >= 2.0.9) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.7.10) + actionpack (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) + nokogiri (>= 1.8.5) + actionview (6.1.7.10) + activesupport (= 6.1.7.10) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.7.10) + activesupport (= 6.1.7.10) + globalid (>= 0.3.6) + activemodel (6.1.7.10) + activesupport (= 6.1.7.10) + activerecord (6.1.7.10) + activemodel (= 6.1.7.10) + activesupport (= 6.1.7.10) + activestorage (6.1.7.10) + actionpack (= 6.1.7.10) + activejob (= 6.1.7.10) + activerecord (= 6.1.7.10) + activesupport (= 6.1.7.10) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.7.10) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.3) + base64 (0.3.0) + bigdecimal (3.2.2) + builder (3.3.0) + byebug (12.0.0) + capybara (3.40.0) addressable + matrix mini_mime (>= 0.1.3) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (>= 2.0, < 4.0) - coderay (1.1.2) - daemons (1.2.6) - diff-lcs (1.3) - eventmachine (1.2.5) - method_source (0.9.0) - mini_mime (1.0.0) - mini_portile2 (2.3.0) - mustermann (1.0.2) - nokogiri (1.8.2) - mini_portile2 (~> 2.3.0) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - public_suffix (3.0.2) - rack (2.0.4) - rack-protection (2.0.1) - rack - rack-test (0.8.2) - rack (>= 1.0, < 3) - rake (12.3.0) - require_all (1.5.0) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + concurrent-ruby (1.3.5) + crass (1.0.6) + date (3.4.1) + diff-lcs (1.6.2) + erubi (1.13.1) + ffi (1.17.2) + ffi (1.17.2-arm64-darwin) + fiddle (1.1.8) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.7) + concurrent-ruby (~> 1.0) + json (2.13.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + logger (1.7.0) + loofah (2.24.1) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + matrix (0.4.3) + method_source (1.1.0) + mini_mime (1.1.5) + mini_portile2 (2.8.9) + minitest (5.25.5) + mutex_m (0.3.0) + net-imap (0.5.9) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.1) + net-protocol + nio4r (2.7.4) + nokogiri (1.18.9) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) + nokogiri (1.18.9-arm64-darwin) + racc (~> 1.4) + ostruct (0.6.3) + parallel (1.27.0) + parser (3.3.9.0) + ast (~> 2.4.1) + racc + prism (1.4.0) + public_suffix (6.0.2) + puma (5.6.9) + nio4r (~> 2.0) + racc (1.8.1) + rack (2.2.17) + rack-cors (2.0.2) + rack (>= 2.0.0) + rack-test (2.2.0) + rack (>= 1.3) + rails (6.1.7.10) + actioncable (= 6.1.7.10) + actionmailbox (= 6.1.7.10) + actionmailer (= 6.1.7.10) + actionpack (= 6.1.7.10) + actiontext (= 6.1.7.10) + actionview (= 6.1.7.10) + activejob (= 6.1.7.10) + activemodel (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) + bundler (>= 1.15.0) + railties (= 6.1.7.10) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.3.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.2) + loofah (~> 2.21) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (6.1.7.10) + actionpack (= 6.1.7.10) + activesupport (= 6.1.7.10) + method_source + rake (>= 12.2) + thor (~> 1.0) + rainbow (3.1.1) + rake (13.3.0) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + regexp_parser (2.11.1) + rspec-core (3.13.5) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) + rspec-support (~> 3.13.0) + rspec-json_expectations (2.2.0) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - shotgun (0.9.2) - rack (>= 1.0) - sinatra (2.0.1) - mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.1) - tilt (~> 2.0) - thin (1.7.2) - daemons (~> 1.0, >= 1.0.9) - eventmachine (~> 1.0, >= 1.0.4) - rack (>= 1, < 3) - tilt (2.0.8) - xpath (3.0.0) + rspec-support (~> 3.13.0) + rspec-rails (5.0.3) + actionpack (>= 5.2) + activesupport (>= 5.2) + railties (>= 5.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.13.4) + rubocop (1.79.2) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.46.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.46.0) + parser (>= 3.3.7.2) + prism (~> 1.4) + ruby-progressbar (1.13.0) + shoulda-matchers (4.5.1) + activesupport (>= 4.2.0) + sprockets (4.2.2) + concurrent-ruby (~> 1.0) + logger + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) + sprockets (>= 3.0.0) + sqlite3 (1.6.9) + mini_portile2 (~> 2.8.0) + stimulus-rails (1.3.4) + railties (>= 6.0.0) + thor (1.4.0) + timeout (0.4.3) + turbo-rails (2.0.12) + actionpack (>= 6.0.0) + railties (>= 6.0.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) + websocket-driver (0.8.0) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.7.3) PLATFORMS + arm64-darwin-24 ruby DEPENDENCIES + bigdecimal + byebug capybara - pry - rack-test - rake - require_all - rspec - shotgun - sinatra - thin + fiddle + listen (~> 3.3) + logger + mutex_m + nio4r (~> 2.7) + ostruct + puma (~> 5.0) + rack-cors + rails (~> 6.1.3, >= 6.1.3.1) + rspec-json_expectations + rspec-rails (~> 5.0.0) + rubocop + shoulda-matchers (~> 4.0) + sprockets-rails + sqlite3 (~> 1.6.0) + stimulus-rails + turbo-rails + tzinfo-data BUNDLED WITH - 1.16.1 + 2.7.1 diff --git a/README.md b/README.md index 1c8ffd2..6a0ac7a 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,18 @@ -# Sinatra Basic Forms Lab +# Rails Basic Forms Lab Your local pet adoption store has asked you to build their new website. First and foremost, the store needs a form for their staff to add puppies that are -available for adoption. Good thing you love puppies _and_ coding! +available for adoption. Good thing you love puppies _and_ coding! ## Objectives 1. Implement a POST request to the controller to display data from a user in -the view + the view 2. Implement both POST and GET requests 3. Connect a controller action with both a view and a model +4. Practice using Rails form helpers and routing ## Instructions @@ -19,33 +20,58 @@ The focus of this lab is to build a way for a user to go to a homepage, follow a link to a form where they can enter a puppy's information, and, upon submission, view the puppy's information. -1. Build out a puppy class in `models/puppy.rb`. Puppies should have name, -breed, and age attributes. You will need to be able to pass these three -attributes to initialization, as well as readers and writers for the attributes. +1. Run `bundle install` +2. Run `bin/rails server` -2. In `app.rb` build out a GET request to load a homepage. The homepage -should go to the main route `/`. +3. **Build out a puppy class** in `app/models/puppy.rb`. Puppies should have name, + breed, and age attributes. You will need to be able to pass these three + attributes to initialization, as well as readers and writers for the attributes. -3. The home page will also need a new view `index.erb`. This page should -welcome you to the Puppy Adoption Site. Add this view to the controller action. +4. **Set up your routes** in `config/routes.rb`: -4. Now, we need to create a form for a user to list a new puppy that is -available for adoption. You can create this form in `views/create_puppy.erb`. -Remember, you'll need to set up another controller action for a user to be -able to view this form in the browser. Another reminder: the "submit" button -of a form is an `` element with a `type` of `"submit"`, *not* a -`