Guest User

Untitled

a guest
Apr 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. ##controller code
  2. #the trouble is that I have a table called 'categories', it contains categories of tutorials and projects.
  3. #unfortunately, some of these categories conflict.
  4. #the database is set up in an :acts_as_tree method - all tutorial categories belong to "tutorials".
  5. #the primary key id is unique, but the path (url-friendly name) by which I reference these categories is not.
  6. class TutorialsController < ApplicationController
  7. def list
  8. #show a list of all tutorials in a category (paginate this)
  9. categories = Category.find_by_path(params[:path])
  10. @category = categories.reject{|category| unless category.root.path == "tutorials"; return true; end}
  11. @tutorials = @category.tutorials
  12. end
  13. end
  14.  
  15. #undefined method `reject' for #<Category:0x2b10bd0dc1b0>
  16. #is the new error I get when I attempt to run this code
Add Comment
Please, Sign In to add comment