{"id":15407109,"url":"https://github.com/ltfschoen/rails_csv_app","last_synced_at":"2026-04-02T04:47:41.824Z","repository":{"id":76620276,"uuid":"84142838","full_name":"ltfschoen/rails_csv_app","owner":"ltfschoen","description":"Upload/persist CSV file to PSQL then search, sort, paginate with AJAX ","archived":false,"fork":false,"pushed_at":"2017-03-07T23:31:22.000Z","size":369,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T03:43:25.998Z","etag":null,"topics":["ajax","boilerplate","bootstrap4","csv","csv-import","faker","jquery3","postgresql","rails5","railscasts","rspec","ruby-gemset","sass","shell","willpaginate"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ltfschoen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-03-07T02:05:33.000Z","updated_at":"2017-03-07T23:04:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"308afde9-828c-4c62-b6fa-ae2e89cd8232","html_url":"https://github.com/ltfschoen/rails_csv_app","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":0.05882352941176472,"last_synced_commit":"b95521411d8e560d7687c1eb0367677327e335cd"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltfschoen%2Frails_csv_app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltfschoen%2Frails_csv_app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltfschoen%2Frails_csv_app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ltfschoen%2Frails_csv_app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ltfschoen","download_url":"https://codeload.github.com/ltfschoen/rails_csv_app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245956322,"owners_count":20700079,"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":["ajax","boilerplate","bootstrap4","csv","csv-import","faker","jquery3","postgresql","rails5","railscasts","rspec","ruby-gemset","sass","shell","willpaginate"],"created_at":"2024-10-01T16:27:05.243Z","updated_at":"2025-12-30T20:31:29.060Z","avatar_url":"https://github.com/ltfschoen.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README\n\n# Screenshot\n\n![alt tag](https://raw.githubusercontent.com/ltfschoen/rails_csv_app/master/screenshot3.png)\n\n---\n\n# Table of Contents\n  * [Instructions](#part-500)\n  * [Goals](#part-750)\n  * [System Requirements and Info](#part-1000)\n  * [Database](#part-1100)\n  * [Documentation Links](#part-1500)\n  * [Setup - Legacy Initial Steps](#part-2000)\n  * [Setup - Replace Unit Test with RSpec](#part-3000)\n  * [Setup - Git Repo](#part-4000)\n  * [Setup - Git Releases and Tags](#part-5000)\n  * [Feature - CSV Upload and Display](#part-6000)\n  * [Feature - Search and Filter Data Uploaded from CSV with Pagination](#part-7000)\n  * [Feature - Bootstrap](#part-8000)\n  * [Feature - Fake CSV Generator](#part-9000)\n\n---\n\n## Instructions \u003ca id=\"part-500\"\u003e\u003c/a\u003e\n\n* Install System Requirements\n* Install Gems `bundle install`\n* Run PostgreSQL\n* Run Rails Server `rails s`\n* Go to http://localhost:3000\n* Click \"Choose File\" (to upload a CSV)\n* Select the [products.csv](https://github.com/ltfschoen/rails_csv_app/blob/master/products.csv) file located in the root directory\n* Click \"Import CSV\"\n* Click the \"1\", \"2\", \"Next\" or \"Previous\" to change Page using Pagination\n* Click the column Labels (i.e. \"Uid\", \"Name\", \"Price\", \"Quantity\", \"Released\") to filter ordering ascending/descending\n* Enter a value in the input field (case sensitive). Click \"Search\" to filter list.\n\n## Goals \u003ca id=\"part-750\"\u003e\u003c/a\u003e\n\n* [X] - Import pre-populated CSV into database from web form.\n* [X] - Present populated data from database in table view\n* [X] - Use AJAX and apply basic filters on table so data updated without refreshing whole page.\n* [X] - Use Sass instead of CSS\n* [X] - Add Bootstrap 4 styling for buttons and tables and Responsive grid\n* [X] - Generate Fake CSV Data\n* [X] - Add Images using LorelPixel\n* [ ] - Switch front-end to React.js or Angular.js instead of jQuery\n* [ ] - Add more Unit Tests\n\n## System Requirements and Info\u003ca id=\"part-1000\"\u003e\u003c/a\u003e\n* Show System Setup\n    `rails about`\n\n* Versions used:\n    * Rails - 5.0.2\n    * Ruby - 2.4.0-p0 (see .ruby-version)\n    * RubyGems - 2.6.10\n    * Ruby Gemset - rails_csv_app (see .ruby-gemset)\n    * Rack - 2.0.1\n    * Node.js - 7.7.1 (V8 runtime)\n    * PostgreSQL - 9.6.2\n    * RSpec - 3.5.4\n    * OS - macOS El Capitan\n\n* Show Codebase Stats\n    `rails stats`\n\n## Database \u003ca id=\"part-1100\"\u003e\u003c/a\u003e\n\n* Run PostgreSQL without background service:\n\t`pg_ctl -D /usr/local/var/postgres start`\n* Configure to start PostgreSQL and restart at login using launchd background service:\n\t`brew services start postgresql`\n* Open PostgreSQL Database console automatically http://guides.rubyonrails.org/command_line.html\n    `rails dbconsole`\n\n* Show database table contents\n    ```\n    select * from products;\n    ```\n\n## Documentation Links \u003ca id=\"part-1500\"\u003e\u003c/a\u003e\n\n* Testing\n    * RSpec Rails https://github.com/rspec/rspec-rails\n\n## Setup - Legacy Initial Steps \u003ca id=\"part-2000\"\u003e\u003c/a\u003e\n\n* Create Project\n\t```\n\trails new rails_csv_app --database=postgresql\n\trvm list\n\t```\n\n* Install latest RVM to install and use latest Ruby version. Update PostgreSQL.\n\t```\n\trvm get master\n\trvm install ruby-2.4.0\n\tbrew upgrade bash\n\tbrew update\n\tbrew reinstall postgresql\n\trvm reinstall ruby-2.4.0\n\trvm use ruby-2.4.0\n\t```\n\n* Update to latest RubyGems version https://rubygems.org/pages/download\n    ```\n    gem install rubygems-update\n    update_rubygems\n    gem update --system\n    ```\n\n* Update to latest JavaScript Runtime. Install NVM.\n  Check latest stable Node.js version https://nodejs.org\n  Check current version and update.\n  Install latest version of NPM.\n    ```\n    node -v\n    npm install -g npm\n    nvm install 7.7.1\n    nvm use 7.7.1\n    ```\n\n* Create custom Gemset with RVM\n\t```\n\trvm gemset create rails_csv_app\n\trvm --ruby-version use 2.4.0@rails_csv_app\n\t```\n\n* Check latest Rails version that is available: https://rubygems.org/gems/rails/versions\n* Install latest specific Rails version\n\t`gem install rails --version 5.0.2`\n\n* Check database.yml is setup correctly for development\n\n* Check that using custom GemSet. Install default Gems in Gemfile\n    ```\n    rvm --ruby-version use 2.4.0@rails_csv_app\n    gem install bundler\n\tbundle install\n\t```\n\n* Migrate into PostgreSQL Database\n\t```\n\trake db:create db:migrate RAILS_ENV=development\n\t```\n\n* Launch the Rails server in separate Terminal tab automatically and opens it in web browser after 10 seconds using Shell Script:\n    `bash launch.sh`\n\n    * Alternatively: Run server command, and then manually go to url, or in a separate tab run command to open app in browser\n    \t`rails s`\n    \t`open http://localhost:3000`\n\n## Setup - Replace Test Unit / Minitest with RSpec \u003ca id=\"part-3000\"\u003e\u003c/a\u003e\n\n* Optionally run Test Unit one last time before sending it to oblivion\n    `rake test`\n\n* Remove Test Unit's directory and files\n    `rm -rf test/`\n\n* Add RSpec to test group within Gemfile to retrieve latest patch https://github.com/rspec/rspec-rails\n    `gem 'rspec-rails', '~\u003e 3.5.2'`\n\n* Check that using Custom GemSet. Install Gems\n    ```\n    rvm --ruby-version use 2.4.0@rails_csv_app\n    bundle install\n    ```\n\n* Initialise /spec directory\n    `rails generate rspec:install`\n\n* Run RSpec tests\n    `rspec`\n\n## Setup - Git Repo \u003ca id=\"part-4000\"\u003e\u003c/a\u003e\n\n* Create new project on GitHub with MIT licence i.e. https://github.com/ltfschoen/rails_csv_app\n\n* Show remote branches for current repo\n    `git remote -v`\n\n* Set a remote URL using SSH\n    `git remote add origin git@github.com:ltfschoen/rails_csv_app.git`\n\n* Use [Bulletproof Git Workflow](https://gist.github.com/ltfschoen/3c7a085f132baf4aff13c9d561b35d03) to rebase with remote branch and get the MIT licence before pushing new changes\n    `git pull --rebase origin master`\n\n* Force push to remote branch to overwrite existing history\n    `git push -f origin master`\n\n## Setup - Git Release and Tags \u003ca id=\"part-5000\"\u003e\u003c/a\u003e\n\n* Create New Release https://github.com/ltfschoen/rails_csv_app/releases/new\n    * Pre-Release (non-production) i.e. v0.1\n\n## Feature - CSV Upload and Display \u003ca id=\"part-6000\"\u003e\u003c/a\u003e\n\n### CSV Setup\n\n* Create new Git branch\n\t```\n\tgit checkout -b feature/csv\n\t```\n\n* Generate Model\n    ```\n    rails g model Product name:string quantity:integer price:decimal comments:string\n    ```\n\n* Modify the migration file as follows:\n\t`t.decimal :price, precision: 12, scale: 2`\n\n* Migrate\n    `rake db:migrate RAILS_ENV=development`\n\n* Generate Controller with index and import Actions\n    `rails g controller Products index import`\n\n* Modify Routes as follows:\n\t```\n\tresources :products do\n\t  collection { post :import }\n\tend\n\n\troot to: \"products#index\"\n\t```\n\n* Update Product Model import function to accept CSV and process each row by\ncomparing with Product table of database, and either updating or creating new entry\n\n* Update Product Controller's index action to fetch all Products to be available in view\nas @products. Also update its import action to call the Product Model's import function\npassing a given file parameter as argument, and then redirecting user to the root url\n\n* Update Product's index View to display list of products, including form allowing user to\nupload the CSV by submitting form\n\n* Create a CSV file called products.csv\n\n* Run server and upload the CSV file, then check it exists in database. Drop database and re-migrate to further test\n\t```\n\trails dbconsole\n\tselect * from products;\n\trake db:drop\n\trake db:create db:migrate RAILS_ENV=development\n\t```\n\n* Add Unit Tests by adding the following gem to allow use of `assigns` in Controller tests\n\t`gem 'rails-controller-testing', '~\u003e 1.0.1'`\n\n* Modify Unit Tests for Product Controller and Model\n\t* Reference: http://stackoverflow.com/questions/15175970/undefined-method-when-running-rspec-test-using-a-stub\n\n* Create New Release https://github.com/ltfschoen/rails_csv_app/releases/new\n    * Feature Release (non-production) i.e. v0.2\n\n## Feature - Search and Filter Data Uploaded from CSV with Pagination \u003ca id=\"part-7000\"\u003e\u003c/a\u003e\n\n* References\n\t* http://stackoverflow.com/questions/28603881/how-to-create-a-ajax-filter-in-the-index-page\n\t* http://railscasts.com/episodes/240-search-sort-paginate-with-ajax\n* Update to jQuery v3 and install jQuery UI Rails\n\t* https://github.com/rails/jquery-rails\n\t\t* Updating app/assets/javascripts/application.js with:\n\t\t\t```\n\t\t\t//= require jquery3\n\t\t\t//= require jquery_ujs\n\t\t\t```\n\t\t* Install jquery-ui-rails Gem\n\t\t\t* https://github.com/jquery-ui-rails/jquery-ui-rails\n\n* Add Willpaginate Gem\n\t* https://github.com/mislav/will_paginate\n\n* Since using latest version of Rails 5.0.2 and Ruby 2.4.0 it was\nnecessary to make the following key changes to the RailsCast #240 code that was\nwritten for Rails 3 back in 2010, to make it run without error:\n    * Replaced `scope` with `where(nil)` in app/models/product.rb\n    * Replaced `params.merge` with `request.parameters` in app/helpers/application_helper.rb\n    * Replaced `sort_column` with `self.sort_column`, and `sort_direction` with `self.sort_direction` in app/helpers/application_helper.rb\n    * Added `include ApplicationHelper` in app/controllers/products_controller.rb\n    * Whitelisted parameters in app/controllers/products_controller.rb with the following and by accessing parameters with `product_params[:search]` instead of just `params[:search]`:\n        ```\n          def product_params\n            params.permit(:id, :uid, :name, :price, :released_at, :search, :page, :sort, :utf8, :direction, :_)\n          end\n        ```\n    * In app/assets/javascripts/application.js, change jQuery `.live`(deprecated) to `.on`\n    * In app/views/products/index.html.erb had to change code to dynamically display title of page by using `\u003c% content_for :title, \"Products\" %\u003e` instead of just `\u003c% title \"Products\" %\u003e`\n\n* Add Sass Rails Gem\n    * http://stackoverflow.com/questions/15257555/how-to-reference-images-in-css-within-rails-4\n\n## Feature - Bootstrap \u003ca id=\"part-8000\"\u003e\u003c/a\u003e\n\n* Bootstrap 4 tables https://v4-alpha.getbootstrap.com/content/tables/\n\n### Feature - Fake CSV Generator \u003ca id=\"part-9000\"\u003e\u003c/a\u003e\n\n* Faked CSV Gem https://github.com/jiananlu/faked_csv\n    * Create file `fake_csv_config.csv.json`\n    * Configure it to output CSV data in format desired and supports Faker Gem https://github.com/stympy/faker\n    * Execute it with the following to generate random CSV:\n        `faked_csv -i fake_csv_config.csv.json -o products.csv`\n    * Insert the Labels at the top of the generated file, i.e.\n        `uid,name,quantity,price,comments,released_at`\n    * Convert image to display correctly\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltfschoen%2Frails_csv_app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fltfschoen%2Frails_csv_app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fltfschoen%2Frails_csv_app/lists"}