Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## new.html.haml
- %h1 New topic
- - form_for(@topic) do |f|
- = f.error_messages
- %p
- = f.label :name
- %br
- = f.text_field :name
- %p
- = f.label :parent
- %br
- = collection_select(:topic, :parent, Topic.all, :id, :name)
- / The above is the offending line of code
- %p= f.submit 'Create'
- = link_to 'Back', topics_path
- ## topics_controller.rb
- def create
- @topic = Topic.new(params[:topic])
- @parent = Topic.find(params[:parent])
- respond_to do |format|
- if @topic.save
- # ...
- ## The error [plain_text]
- ActiveRecord::UnknownAttributeError in TopicsController#create
- unknown attribute: parent
- ## topic.rb
- class Topic < ActiveRecord::Base
- has_many :lessons
- has_many :sections
- has_many :topics, :id => :lft # should I do something like this to make standard AR association stuff work?
- acts_as_nested_set
- end
Add Comment
Please, Sign In to add comment