RailsCasts Pro episodes are now free!

Learn more or hide this

Clinton Cecil's Profile

GitHub User: thatRailsGuy

Comments by Clinton Cecil

Avatar

Not sure if you figured it out, but just ran into the same problem.

in the strong_params method, you must make tags an array

ruby
def article_params
  params.require(:article).permit(:name, :content, :published_at, tags: [])
end
Avatar

To use multicolumn sorting, I did this:

ruby
  def sort_helper
    columns = %w[name category released_on price]
    sort = "#{sort_column} #{sort_direction}"
    (params[:iSortingCols].to_i-1).times do |i|
      sort << ", #{columns[params["iSortCol_#{i+1}"].to_i]} #{params["sSortDir_#{i+1}"] == "desc" ? "desc" : "asc"}"
    end
    sort
  end
  def fetch_products
      products = Product.order("#{sort_helper}")
      products = products.page(page).per_page(per_page)
      if params[:sSearch].present?
        products = products.where("name like :search or category like :search", search: "%#{params[:sSearch]}%")
      end
      products
    end