diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index af964a3..d76df10 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -1,6 +1,6 @@ class ForumthreadsController < ApplicationController def index - f = Forum.find(params[:id]) + f = Forum.find(params[:forum_id]) redirect_to forum_path(f.forumgroup, f) end @@ -10,7 +10,7 @@ class ForumthreadsController < ApplicationController end def new - @forum = Forum.find(params[:id]) + @forum = Forum.find(params[:forum_id]) if @forum && current_user && (@forum.group.role_read.nil? || @forum.group.role_read <= current_user.role) && (@forum.role_read.nil? || @forum.role_read <= current_user.role) @thread = Forumthread.new(forum: @forum) else @@ -20,14 +20,14 @@ class ForumthreadsController < ApplicationController end def create - @forum = Forum.find(params[:id]) + @forum = Forum.find(params[:forum_id]) if (confirmed? && (@forum.group.role_read || Role.get(:default))<= current_user.role && (@forum.group.role_write || Role.get(:default))<= current_user.role && (@forum.role_read || Role.get(:default))<= current_user.role && (@forum.group.role_write || Role.get(:default))<= current_user.role) @thread = Forumthread.new(mod? ? params[:forumthread] : params[:forumthread].slice(:title, :content)) @thread.user_author = current_user @thread.forum = @forum if @thread.save flash[:notice] = "Thread created!" - redirect_to @thread + redirect_to forum_forumthread_path(@forum, @thread) return else flash[:alert] = "Seomthing went wrong while creating your thread." diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 2f681fa..e3379b3 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -1,10 +1,17 @@ <%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= link_to @forum %> -

<%= @forum.name %>

-<%= link_to "New thread", new_forum_forumthread_path(@forum), class: "btn blue" %> -
- <% @threads.each do |thread| %> -
- <%= link_to thread.title, forum_forumthread_path(@forum, thread) %> + +

<%= link_to "New thread", new_forum_forumthread_path(@forum), class: "btn blue" %>

+ +
+
+
+ <%= @forum.name %> <%= link_to "edit", edit_forum_path(@forum), class: "editlink" %>
- <% end %> -
\ No newline at end of file +
+ <% @threads.select{ |t| t.sticky }.each do |thread| %> + <%= link_to thread.title, forum_forumthread_path(@forum, thread), class: "forum sticky" %> + <% end %> + <% @threads.reject{ |t| t.sticky }.each do |thread| %> + <%= link_to thread.title, forum_forumthread_path(@forum, thread), class: "forum" %> + <% end %> +
\ No newline at end of file diff --git a/app/views/forumthreads/new.html.erb b/app/views/forumthreads/new.html.erb index af7bdc5..c8a2393 100644 --- a/app/views/forumthreads/new.html.erb +++ b/app/views/forumthreads/new.html.erb @@ -1,6 +1,6 @@ <%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= link_to @forum, @forum %> → New thread

New thread

-<%= simple_form_for @thread do |f|%> +<%= simple_form_for [@forum, @thread] do |f|%>
<%= f.label :title %> <%= f.label :content, "Text" %>