Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: app/models/forum.rb
- ===================================================================
- --- app/models/forum.rb (revision 2428)
- +++ app/models/forum.rb (working copy)
- @@ -1,5 +1,6 @@
- class Forum < ActiveRecord::Base
- - acts_as_list
- + acts_as_list :scope => :parent_id
- + acts_as_tree
- validates_presence_of :name
- Index: app/controllers/forums_controller.rb
- ===================================================================
- --- app/controllers/forums_controller.rb (revision 2428)
- +++ app/controllers/forums_controller.rb (working copy)
- @@ -3,7 +3,8 @@
- before_filter :find_or_initialize_forum, :except => :index
- def index
- - @forums = Forum.find(:all, :order => "position")
- + # only 1 level of children due to limitations of acts_as_tree (unless we do a lot more sql)
- + @forums = Forum.find(:all, :conditions => 'parent_id IS NULL').collect{ |f| [f, f.children] }.flatten
- end
- def show
- Index: app/views/forums/_form.rhtml
- ===================================================================
- --- app/views/forums/_form.rhtml (revision 2428)
- +++ app/views/forums/_form.rhtml (working copy)
- @@ -16,6 +16,16 @@
- </table>
- </p>
- -<p id="forum_descripion">
- +
- +<p id ="forum_category">
- +<%= f.check_box :category %><label>Category only</label>
- +</p>
- +
- +<p id ="forum_parent_id">
- +<label>Parent forum/category (blank for root)</label><br />
- +<%= f.select :parent_id, Forum.find(:all, :conditions => 'parent_id IS NULL').collect {|o| [ o.name, o.id ] }, { :include_blank => true } %>
- +</p>
- +
- +<p id="forum_description">
- <label>Description</label><br />
- <%= f.text_area :description, :rows => 7 %></p>
- \ No newline at end of file
- Index: app/views/forums/index.rhtml
- ===================================================================
- --- app/views/forums/index.rhtml (revision 2428)
- +++ app/views/forums/index.rhtml (working copy)
- @@ -8,7 +8,7 @@
- <% if admin? %>
- <h6>Admin</h6>
- -<p><%= link_to 'Create New Forum', new_forum_path, :class => "utility" %></p>
- +<p><%= link_to 'Create New Forum/Category', new_forum_path, :class => "utility" %></p>
- <% end %>
- <% end %>
- @@ -32,6 +32,19 @@
- </tr>
- <% for forum in @forums do %>
- <tr>
- + <% if forum.category -%>
- + <td class="vat c1">
- + </td>
- + <td class="c2" colspan=2>
- + <%= link_to "Edit", edit_forum_path(forum), :class => "tiny", :rel => "directory", :style => "float:right" if admin? %>
- + <div class="title">
- + <%= forum.name %>
- + </div>
- + <p class="desc">
- + <%= forum.description_html %>
- + </p>
- + </td>
- + <% else -%>
- <td class="vat c1">
- <% if recent_forum_activity(forum) %>
- @@ -40,7 +53,7 @@
- <%= image_tag "clearbits/comment.gif", :class => "icon grey", :title => "No recent activity" %>
- <% end %>
- </td>
- - <td class="c2">
- + <td class="c2" <%= 'style=padding-left:'+(5+(forum.ancestors.size*15)).to_s+'px' if forum.ancestors.size > 0 -%>>
- <%= link_to "Edit", edit_forum_path(forum), :class => "tiny", :rel => "directory", :style => "float:right" if admin? %>
- <%= link_to h(forum.name), forum_path(forum), :class => "title" %>
- @@ -63,6 +76,7 @@
- <span>(<%= link_to 'view', topic_path(:forum_id => forum, :id => forum.posts.last.topic_id, :page => forum.posts.last.topic.last_page, :anchor => forum.posts.last.dom_id) %>)</span>
- <% end %>
- </td>
- + <% end -%>
- </tr>
- <% end %>
- </table>
Add Comment
Please, Sign In to add comment