From c4b8fb35183ab1a1972a7b64da900b277424189a Mon Sep 17 00:00:00 2001 From: Michael Hartl Date: Thu, 18 Aug 2016 18:27:26 -0700 Subject: [PATCH] Add message partials --- app/views/messages/_message.html.erb | 8 ++++++++ app/views/messages/_message_form.html.erb | 6 ++++++ app/views/messages/_messages.html.erb | 7 +++++++ app/views/messages/index.html.erb | 25 ++--------------------- 4 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 app/views/messages/_message.html.erb create mode 100644 app/views/messages/_message_form.html.erb create mode 100644 app/views/messages/_messages.html.erb diff --git a/app/views/messages/_message.html.erb b/app/views/messages/_message.html.erb new file mode 100644 index 000000000..2e2cdc5ca --- /dev/null +++ b/app/views/messages/_message.html.erb @@ -0,0 +1,8 @@ +
+
+ <%= message.user.username %>: +
+
+ <%= message.content %> +
+
diff --git a/app/views/messages/_message_form.html.erb b/app/views/messages/_message_form.html.erb new file mode 100644 index 000000000..8a4e4ff00 --- /dev/null +++ b/app/views/messages/_message_form.html.erb @@ -0,0 +1,6 @@ +
+ <%= form_for(@message) do |f| %> + <%= f.text_area :content %> + <%= f.submit "Send" %> + <% end %> +
diff --git a/app/views/messages/_messages.html.erb b/app/views/messages/_messages.html.erb new file mode 100644 index 000000000..2a8fbf2ee --- /dev/null +++ b/app/views/messages/_messages.html.erb @@ -0,0 +1,7 @@ +
+
+ <% if @messages.any? %> + <%= render @messages %> + <% end %> +
+
\ No newline at end of file diff --git a/app/views/messages/index.html.erb b/app/views/messages/index.html.erb index 2182b8cfb..a26da38de 100644 --- a/app/views/messages/index.html.erb +++ b/app/views/messages/index.html.erb @@ -1,25 +1,4 @@
-
-
- <% if @messages && @messages.any? %> - <% @messages.each do |message| %> -
-
- <%= message.user.username %>: -
-
- <%= message.content %> -
-
- <% end %> - <% end %> -
-
- -
- <%= form_for(@message) do |f| %> - <%= f.text_area :content %> - <%= f.submit "Send" %> - <% end %> -
+ <%= render 'messages' %> + <%= render 'message_form' %>
\ No newline at end of file