Refactor message creation to use a create action

This makes it more conventional, rather than handling posts to the new action. The posting of the form was also reworked to use a hidden field for the displayname, rather than in the url, again for convention.
This commit is contained in:
Andy Allan 2018-08-29 14:18:20 +08:00
parent 06915a77b5
commit f38e03f0ed
5 changed files with 40 additions and 33 deletions

View file

@ -1194,6 +1194,7 @@ en:
body: "Body"
send_button: "Send"
back_to_inbox: "Back to inbox"
create:
message_sent: "Message sent"
limit_exceeded: "You have sent a lot of messages recently. Please wait a while before trying to send any more."
no_such_message:

View file

@ -264,7 +264,7 @@ OpenStreetMap::Application.routes.draw do
get "/export/embed" => "export#embed"
# messages
resources :messages, :only => [:show] do
resources :messages, :only => [:create, :show] do
collection do
get :inbox
get :outbox
@ -272,7 +272,7 @@ OpenStreetMap::Application.routes.draw do
end
get "/user/:display_name/inbox", :to => redirect(:path => "/messages/inbox")
get "/user/:display_name/outbox", :to => redirect(:path => "/messages/outbox")
match "/message/new/:display_name" => "messages#new", :via => [:get, :post], :as => "new_message"
get "/message/new/:display_name" => "messages#new", :as => "new_message"
get "/message/read/:message_id", :to => redirect(:path => "/messages/%{message_id}")
post "/message/mark/:message_id" => "messages#mark", :as => "mark_message"
match "/message/reply/:message_id" => "messages#reply", :via => [:get, :post], :as => "reply_message"