Today I have been studying a railscasts for trees with Ancestry.
"http://railscasts.com/episodes/262-trees-with-ancestry?view=asciicast"
First of all, I created the model for Message. The problem is the model Message appears empty in the example code. To have the example running before using Ancestry, you need the following code:
class Message < ActiveRecord::Base
attr_accessible :content
end
And the schema has to be:
create_table "messages", :force => true do |t|
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "content"
end
A thing that I made different from the railscast is using simple_form for the form. The code I used is:
<%= simple_form_for @message, html: { class: 'form-horizontal' } do |f| %>
<%= f.error_notification %>
<%= f.hidden_field :parent_id %>
<%= f.input :content, label: 'New Message', :input_html => { :rows => 8 } %>
<%= f.button :submit, "Post Message" %>
<% end %>
I wasn't able to apply an indent in the nested messages using css, but at least I have ancestry running.
Step by step.
Keine Kommentare:
Kommentar veröffentlichen