]> git.openstreetmap.org Git - rails.git/commitdiff
nicer reply messages, bug 529
authorSteve Coast <steve@asklater.com>
Sat, 3 May 2008 14:02:53 +0000 (14:02 +0000)
committerSteve Coast <steve@asklater.com>
Sat, 3 May 2008 14:02:53 +0000 (14:02 +0000)
app/controllers/message_controller.rb
app/views/message/new.rhtml

index 395d56028999d92a99a70e4b20d020942aa0d1d9..8aecef98e56a87059595550c72064170fca66501 100644 (file)
@@ -34,8 +34,10 @@ class MessageController < ApplicationController
 
   def reply
     message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
 
   def reply
     message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
-    title = message.title.sub(/^Re:\s*/, "Re: ")
-    redirect_to :action => 'new', :user_id => message.from_user_id, :title => title
+    @body = "\n\nOn #{message.sent_on} #{message.sender.display_name} wrote:\n #{message.body}" 
+    @title = "Re: #{message.title}"
+    @user_id = message.from_user_id
+    render :action => 'new'
   rescue ActiveRecord::RecordNotFound
     render :nothing => true, :status => :not_found
   end
   rescue ActiveRecord::RecordNotFound
     render :nothing => true, :status => :not_found
   end
index d66e7caedb8773d0aa4134cd812d27e8228f8603..723cb1f10277bcffcac5c8dc9b725f54c06b2411 100644 (file)
@@ -1,4 +1,4 @@
-<% display_name = User.find_by_id(params[:user_id]).display_name %>
+<% display_name = User.find_by_id(params[:user_id] || @user_id).display_name %>
 <% title = params[:message] ? params[:message][:title] : params[:title] %>
 
 <h2>Send a new message to <%= h(display_name) %></h2>
 <% title = params[:message] ? params[:message][:title] : params[:title] %>
 
 <h2>Send a new message to <%= h(display_name) %></h2>
 
 <%= error_messages_for 'message' %>
 
 
 <%= error_messages_for 'message' %>
 
-<% form_for :message do |f| %>
+<% form_for :message, :url => {:user_id => params[:user_id] || @user_id,  :action => "new" } do |f| %>
   <table>
     <tr valign="top">
       <th>Subject</th>
   <table>
     <tr valign="top">
       <th>Subject</th>
-      <td><%= text_field_tag 'message[title]', title, :size => 60 %></td>
+      <td><%= text_field_tag 'message[title]', title, :size => 60, :value => @title %></td>
     </tr>
     <tr valign="top">
       <th>Body</th>
     </tr>
     <tr valign="top">
       <th>Body</th>
-      <td><%= f.text_area :body, :cols => 80 %></td>
+      <td><%= f.text_area :body, :cols => 80, :value => @body %></td>
     </tr>
     <tr>
       <th></th>
     </tr>
     <tr>
       <th></th>
-      <td><%= submit_tag 'Send' %></td>
+      <td><%= submit_tag 'Send', :action => 'new' %></td>
     </tr>
   </table>
 <% end %>
     </tr>
   </table>
 <% end %>