{"id":19558316,"url":"https://github.com/sbimochan/rails_coursera_ar_1","last_synced_at":"2026-05-15T06:35:53.173Z","repository":{"id":106953119,"uuid":"122475187","full_name":"sbimochan/rails_coursera_ar_1","owner":"sbimochan","description":null,"archived":false,"fork":false,"pushed_at":"2020-07-21T09:32:28.000Z","size":45,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-08T22:03:40.952Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbimochan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-22T12:24:49.000Z","updated_at":"2018-02-22T12:25:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"534a4a2b-c5e8-471d-afda-5f28332f08f6","html_url":"https://github.com/sbimochan/rails_coursera_ar_1","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbimochan%2Frails_coursera_ar_1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbimochan%2Frails_coursera_ar_1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbimochan%2Frails_coursera_ar_1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbimochan%2Frails_coursera_ar_1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbimochan","download_url":"https://codeload.github.com/sbimochan/rails_coursera_ar_1/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240814857,"owners_count":19861958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T04:46:47.177Z","updated_at":"2026-05-15T06:35:53.101Z","avatar_url":"https://github.com/sbimochan.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Assignment for Module #1: Basic Active Record CRUD\n\nThe overall goal of this assignment is to assess your ability to implement basic CRUD functionality of Active Record. This includes:\n\n  * Creating Active Record Models using a rails-provided generator (`rails g model` or `rails g scaffold`)\n  * Creating a DataBase (DB) schema\n  * Inserting rows in the DB\n  * Updating rows in the DB\n  * Querying the DB with exact matching\n  * Getting rows from the DB by Primary Key (PK)\n  * Deleting rows from the DB\n  * Retrieving paginated results from the DB using `limit` and `offset` keywords\n\nThis does NOT include: \n  \n  * Seeding with seeds.rb\n  * Relationships\n  * Validations \n  * Advanced queries \n\nThese topics of Active Record are covered in Module 2.\n\nThe functional goal of this assignment is to implement CRUD behavior for four (4) Model classes\n  \n  1. User\n  2. Profile\n  3. TodoList\n  4. TodoItem\n\n### Functional Requirements\n\n1. Create several Active Record Model classes\n    * User\n    * Profile\n    * TodoList\n    * TodoItem\n\n2. Create a DB schema for each Model class\n\n3. Demonstrate CRUD access to information in the DB using Active Record Model methods.\n\n### Getting Started\n\n1. Create a new Rails application called `todolists`.\n\n2. Add the following specification to your Gemfile to enable rspec testing.\n\n    ```ruby\n    group :test do\n      gem 'rspec-rails', '~\u003e 3.0'\n    end\n    ```\n3. Run the `bundle` command to resolve new gems \n\n4. From the `todolists` application root directory, initialize the rspec tests using \n  `rails generate rspec:install` command.\n\n    ```shell\n      [todolists]$ rails generate rspec:install\n      create  .rspec\n      create  spec\n      create  spec/spec_helper.rb\n      create  spec/rails_helper.rb\n    ```\n\n    Add the following line to `.rspec` to add verbose output to test results.\n\n    ```shell\n    --format documentation\n    ```\n\n5. Download and extract the starter set of boostrap files. \n\n    ```shell\n    |-- Gemfile\n    |-- assignment\n    |   `-- assignment.rb\n    `-- spec\n        `-- assignment_spec.rb\n    ```\n\n    * overwrite your existing Gemfile with the Gemfile from the bootstrap fileset. They \n    should be nearly identical, but this is done to make sure the gems and versions you use in \n    your solution can be processed by the automated Grader when you submit. Any submission\n    should be tested with this version of the file.\n\n    * add the `assignment/assignment.rb` file provided with the boostrap fileset to a \n    corresponding `assignment` directory under your application root directory \n    (e.g., `application-root-directory/assignment/assignment.rb`). \n    (Note: You will need to create the `assignment` directory if you are copying the file.) \n    The `assignment.rb` file contains a skeleton of methods for you to implement as part of your assignment.\n\n    * add the `spec/assignment_spec.rb` file provided with the bootstrap fileset to \n    the corresponding `spec` directory that already exists under your application root directory \n    (e.g., `application-root-directory/spec/assignment_spec.rb`). \n    This `assignment_spec.rb` file contains tests that will help determine whether \n    you have completed the assignment.\n\n6. Run the rspec test(s) to receive feedback. `rspec` must be run from the root directory\nof your application.  All tests will (obviously) fail until you complete the specified solution.\n\n    ```shell\n    $ rspec \n    ...\n    Finished in 0.02069 seconds (files took 1.63 seconds to load)\n    52 examples, 1 failure, 50 pending\n    ```\n\n    To focus test feedback on a specific step of the requirements, add \"-e rq##\" to the\n    rspec command line to only evaluate that requirement. Pad all step numbers to two \n    digits.\n\n    ```shell\n    $ rspec -e rq01\n    Run options: include {:full_description=\u003e/rq01/}\n\n    Assignment\n      rq01\n        Generate Rails application\n          must have top level structure of a rails application\n\n    Finished in 0.00465 seconds (files took 1.56 seconds to load)\n    1 example, 0 failures\n    ```\n\n7. Implement your Model and assignment.rb solution and use the rspec tests to help \nverify your completed solution.\n\n8. Submit your Rails app solution for grading.\n\n### Technical Requirements\n\n1. Create a new Rails app called `todolists`. \n\n    ```shell\n    $ rspec -e rq01\n    ```\n\n   Note: Use the Gemfile provided in the boostrap files. \n   Windows users may need to add this gem into the Gemfile:\n\n   ```ruby\n   # Windows does not include zoneinfo files, so bundle the tzinfo-data gem\n   gem 'tzinfo-data', platforms: [:mingw, :mswin]\n   ```\n\n   Otherwise, do not change the Gemfile from what is provided\n   or your submitted solution may not be able to be processed by the grader\n   (i.e., do not add any additional gems or change gem versions).\n\n2. Generate four (4) model classes and DB migrations having the following\nbusiness-related fields using one of the `rails generate` commands.\n   \n    You can individually grade your results after each model class is created \n    by migrating the database and running the rspec test listed after each \n    classname. Example:\n\n    ```shell\n    $ rake db:migrate\n    $ rspec -e rq02.1\n    ```\n    \n    1. User (`rq02.1`)\n\n        - username - a string to hold account identity\n        - password_digest - a string to hold password information\n    \n    2. Profile (`rq02.2`)\n    \n        - gender - a string to hold the words \"male\" or \"female\"\n        - birth_year - a number to hold the year the individual was born\n        - first_name - a string with given name of user\n        - last_name - a string with family name of user\n    \n    3. TodoList (`rq02.3`)\n        \n        - list_name - a string name assigned to the list\n        - list_due_date - a date when TODO items in the list are to be complete.\n        This is a date. We are not concerned with the time of day.\n    \n    4. TodoItem (`rq02.4`)\n        \n        - due_date - date when the specific task is to be complete\n        - title - a string with short name for specific task\n        - description - a text field with narrative text for specific task\n        - completed - a boolean value (default=false), indicating whether item is complete\n\n    Reminder: Ruby/Rails conventions are that class names are CamelCase and file \n    and method names are snake_case.\n    \n    Note: We will only be using the Model and DB migration classes for this\n    assignment. It is assumed that each Model will also contain the `id`, \n    `created_at`, and `updated_at` fields. All four (4) Model Classes/DB tables\n    must be created, but the detailed tests will be focused on the User and TodoList\n    only. You will use the remaining classes more in a follow-on assignment.\n\n3. Insert rows in DB\n\n    1. Implement the `create_user` method within `assignment/assignment.rb` to \n\n        * accept a hash of user properties (`:username` and `:password_digest`) as an input parameter. \n        Note these are 100% same as model class.\n        * use the User Model class to create a new user in the DB\n        * return an instance of the class with primary key (`id`), and dates (`created_at` and `updated_at`) assigned\n    \n        ```script\n        $ rspec -e rq03.1\n        ```\n\n    2. Implement the `create_todolist` method within `assignment/assignment.rb` to \n\n        * accept a hash of todolist properties (`:name` and `:due_date`) as an input parameter. \n        __Note__ these hash keys are not 100% the same as Model class. Your solution must convert these \n        properties into hash with keys Active Record will accept for the schema for the class.\n        * use the TodoList Model class to create a new todolist in the DB\n        * return an instance of the class with primary key (`id`), and dates (`created_at` and `updated_at`) assigned\n    \n        ```script\n        $ rspec -e rq03.2\n        ```\n\n4. Retrieve paginated results from DB\n\n    1. Implement the `find_allusers` method within `assignment/assignment.rb` to \n\n        * accept offset and limit input parameters\n        * use the User Model class to find all Users, ordered by `updated_at` ascending, with specified row offset and row limit\n        * return a collection of User instances that represent the specified page\n    \n        ```script\n        $ rspec -e rq04.1\n        ```\n    \n    2. Implement the `find_alllists` method within `assignment/assignment.rb` to \n\n        * accept offset and limit input parameters\n        * use the TodoList Model class to find all TodoLists, ordered by `list_due_date` descending, with specified row offset and row limit\n        * return a collection of TodoList instances that represent the specified page\n    \n        ```script\n        $ rspec -e rq04.2\n        ```\n\n5. Query DB with exact match\n\n    1. Implement the `find_user_byname` method within `assignment/assignment.rb` to \n\n        * accept a username input parameter\n        * use the User Model class to find all Users with the supplied username. Note that we have not yet constrained the username to be unique.\n        * return a collection of User instances that match the provided username\n    \n        ```script\n        $ rspec -e rq05.1\n        ```\n    \n    2. Implement the `find_todolist_byname` method within `assignment/assignment.rb` to \n\n        * accept a name input parameter\n        * use the TodoList Model class to find all TodoLists with the supplied list_name. Note that list_name is not required to be unique.\n        * return a collection of TodoList instances that match the provided name\n    \n        ```script\n        $ rspec -e rq05.2\n        ```\n\n6. Get rows from DB by PK\n\n    1. Implement the `get_user_byid` method within `assignment/assignment.rb` to \n\n        * accept an id input parameter\n        * use the User Model class to get the User associated with the `id` primary key\n        * return the User instance that matches the provided id\n    \n        ```script\n        $ rspec -e rq06.1\n        ```\n\n    2. Implement the `get_todolist_byid` method within `assignment/assignment.rb` to \n\n        * accept an id input parameter\n        * use the TodoList Model class to get the TodoList associated with the `id` primary key\n        * return the TodoList instance that matches the provided id\n    \n        ```script\n        $ rspec -e rq06.2\n        ```\n\n7. Update rows in DB\n\n    1. Implement the `update_password` method within `assignment/assignment.rb` to \n\n        * accept an id and password_digest input parameters\n        * use the User Model class to update the `password_digest` for the User associated with the id primary key\n        * (no return is required)\n    \n        ```script\n        $ rspec -e rq07.1\n        ```\n\n    2. Implement the `update_listname` method within `assignment/assignment.rb` to \n\n        * accept an id and name input parameters\n        * use the TodoList Model class to update the `list_name` for the TodoList associated with id primary key \n        * (no return is required)\n    \n        ```script\n        $ rspec -e rq07.2\n        ```\n\n8. Delete rows from DB\n\n    1. Implement the `delete_user` method within `assignment/assignment.rb` to \n\n        * accept an id input parameter\n        * use the User Model class to delete the User associated with the `id` primary key from the database\n        * (no return is required)\n    \n        ```script\n        $ rspec -e rq08.1\n        ```\n\n    2. Implement the `delete_todolist` method within `assignment/assignment.rb` to \n\n        * accept an id input parameter\n        * use the TodoList Model class to delete the TodoList associated with the `id` primary key.\n        * (no return is required)\n    \n        ```script\n        $ rspec -e rq08.2\n        ```\n\n### Self Grading/Feedback\n\nSome unit tests have been provided in the bootstrap files and provide \nexamples of tests the grader will be evaluating for when you submit \nyour solution. They must be run from the project root directory.\n\n```shell\n$ rspec \n...\nFinished in 3.39 seconds (files took 1.47 seconds to load)\n52 examples, 0 failures\n```\n\nYou can run as many specific tests you wish be adding `-e rq## -e rq##`\n\n```shell\n$ rspec -e rq01 -e rq02\n```\n\n### Submission\n\nSubmit an .zip archive (other archive forms not currently supported)\nwith your solution root directory as the top-level (e.g., your Gemfile\nand sibling files must be in the root of the archive and *not* in a\nsub-folder.  The grader will replace the spec files with fresh copies\nand will perform a test with different query terms.\n\n```text\n|-- app\n|   |-- assets\n|   |-- controllers\n|   |-- helpers\n|   |-- mailers\n|   |-- models\n|   `-- views\n|-- assignment\n|   `-- assignment.rb\n|-- bin\n|-- config\n|-- config.ru\n|-- db\n|-- Gemfile\n|-- Gemfile.lock\n|-- lib\n|-- log\n|-- public\n|-- Rakefile\n|-- README.rdoc\n|-- test\n`-- vendor\n```\n\n#### Last Updated: 2015-10-29\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbimochan%2Frails_coursera_ar_1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbimochan%2Frails_coursera_ar_1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbimochan%2Frails_coursera_ar_1/lists"}