Permalink
Browse files

Use route instead of query string for replies. Eliminate global variable

in leafs controller.
  • Loading branch information...
1 parent bd12b6f commit 46372da21b86b895d3f4216dab3e2b4da05e6a65 @mcfiredrill committed May 29, 2011
@@ -1,16 +1,15 @@
class LeafsController < ApplicationController
def new
@leaf = Leaf.new
- @branch = Branch.find(params[:branch])
- $theid = @branch.id
+ @branch = Branch.find(params[:id])
respond_to do |format|
format.html
end
end
def create
- @parentbranch = Branch.find($theid)
+ @parentbranch = Branch.find(params[:branch_id])
@leaf = Leaf.new(params[:leaf])
@leaf.branch_id = @parentbranch.id
@@ -25,7 +24,7 @@ def create
format.html { redirect_to new_branch_path }
end
else
- @branch = Branch.find($theid)
+ @branch = Branch.find(params[:branch_id])
format.html { render :action => "new" }
end
end
@@ -4,7 +4,7 @@
%div.branch
%div{:class => "firstleaf", :id => "#{f.id}"}
- if !reply_mode?
- %div.replylink=link_to 'Reply', "/leafs/new?branch=#{branch.id}"
+ %div.replylink=link_to 'Reply', "/leafs/new/#{branch.id}"
= render f
- for i in 1..branch.leafs.length-1
%div{:class => "leaf", :id => "#{branch.leafs[i].id}"}
@@ -1,4 +1,4 @@
-= render :partial => "layouts/form", :locals => { :newpost => @branch, :leaf => @leaf }
+= render :partial => "layouts/form", :locals => { :newpost => @branch, :leaf => @leaf, :branch => @branch }
= form_for :branch, :html => { :method => :delete } do |del|
= render :partial => 'cur_page', :locals => { :del => del }
@@ -9,6 +9,7 @@
%div.postarea_container
= fields_for leaf do |l|
%div.postarea
+ = hidden_field_tag("branch_id", branch.id)
%table
%tr
%td.fieldlabel Name
@@ -5,5 +5,5 @@
%div.replyheader Posting mode: Reply
-= render :partial => "layouts/form", :locals => { :newpost => @leaf, :leaf => @leaf }
+= render :partial => "layouts/form", :locals => { :newpost => @leaf, :leaf => @leaf, :branch => @branch }
= render @branch
View
@@ -3,6 +3,8 @@
resources :branches
+ match 'leafs/new/:id' => 'leafs#new'
+
# The priority is based upon order of creation:
# first created -> highest priority.
View
@@ -20,7 +20,6 @@
end
create_table "branches", :force => true do |t|
- t.string "name"
t.datetime "last_post_at"
t.datetime "created_at"
t.datetime "updated_at"

0 comments on commit 46372da

Please sign in to comment.