Sign in through GitHub

RailsCasts Pro episodes are now free!

Learn more or hide this

Luke Schoen's Profile

GitHub User: ltfschoen


Comments by Luke Schoen


I created an app rails_csv_app using code from this RailsCast plus I added functionality for a user to upload a CSV file that persists to a PostgreSQL database and is displayed in the view. It was a code test for a potential job opportunity using the latest version of Rails 5.0.2 and Ruby 2.4.0. It was necessary to make these key changes to make it work:

  • Replaced scope with where(nil) in app/models/product.rb
  • Replaced params.merge with request.parameters in app/helpers/application_helper.rb
  • Replaced sort_column with self.sort_column, and sort_direction with self.sort_direction in app/helpers/application_helper.rb
  • Added include ApplicationHelper in app/controllers/products_controller.rb
  • Whitelisted parameters in app/controllers/products_controller.rb with the following and by accessing parameters with product_params[:search] instead of just params[:search]:
  def product_params
    params.permit(:id, :name, :price, :released_at, :search, :page, :sort, :utf8, :direction)
  • In app/views/products/index.html.erb had to change code to dynamically display title of page by using <% content_for :title, "Products" %> instead of just <% title "Products" %>
  • Other improvements beside the core functionality would be to use div's instead of table's, Bootstrap or Foundation Grid, and custom button and table styling