Guest User

Untitled

a guest
Jun 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. ## new.html.haml
  2. %h1 New topic
  3.  
  4. - form_for(@topic) do |f|
  5. = f.error_messages
  6.  
  7. %p
  8. = f.label :name
  9. %br
  10. = f.text_field :name
  11.  
  12. %p
  13. = f.label :parent
  14. %br
  15. = collection_select(:topic, :parent, Topic.all, :id, :name)
  16. / The above is the offending line of code
  17. %p= f.submit 'Create'
  18.  
  19. = link_to 'Back', topics_path
  20.  
  21. ## topics_controller.rb
  22. def create
  23. @topic = Topic.new(params[:topic])
  24. @parent = Topic.find(params[:parent])
  25. respond_to do |format|
  26. if @topic.save
  27. # ...
  28.  
  29. ## The error [plain_text]
  30. ActiveRecord::UnknownAttributeError in TopicsController#create
  31.  
  32. unknown attribute: parent
  33.  
  34. ## topic.rb
  35.  
  36. class Topic < ActiveRecord::Base
  37. has_many :lessons
  38. has_many :sections
  39. has_many :topics, :id => :lft # should I do something like this to make standard AR association stuff work?
  40. acts_as_nested_set
  41. end
Add Comment
Please, Sign In to add comment