diff --git a/app/assets/stylesheets/microposts.css b/app/assets/stylesheets/microposts.css index c81faa8..edcb4ec 100644 --- a/app/assets/stylesheets/microposts.css +++ b/app/assets/stylesheets/microposts.css @@ -23,6 +23,10 @@ form#micropost_form { } } +ul#microposts { + list-style-type: none; +} + .micropost { margin: 1em auto; padding: .5em; @@ -33,4 +37,16 @@ form#micropost_form { text-align: right; font-size: .8em; } + + h5 { + display: inline; + } + + ul.micropost-tags { + list-style-type: none; + display: inline; + li { + display: inline; + } + } } diff --git a/app/controllers/microposts_controller.rb b/app/controllers/microposts_controller.rb index 2e4a373..c87e501 100644 --- a/app/controllers/microposts_controller.rb +++ b/app/controllers/microposts_controller.rb @@ -17,6 +17,7 @@ class MicropostsController < ApplicationController def create micropost = Micropost.new(micropost_params) micropost.user = helpers.current_user + micropost.add_tags(params[:tags]) if micropost.save redirect_to micropost, notice: t(".created") else @@ -46,6 +47,10 @@ class MicropostsController < ApplicationController private + def parse_tags(tags) + tags.split + end + def micropost_params params.require(:micropost).permit( :content, diff --git a/app/views/microposts/_form.html.erb b/app/views/microposts/_form.html.erb index aad2958..476dfdf 100644 --- a/app/views/microposts/_form.html.erb +++ b/app/views/microposts/_form.html.erb @@ -3,5 +3,7 @@ <%= f.rich_text_area :content %> + <%= text_field_tag :tags %> + <%= f.submit button_text %> <% end %> diff --git a/app/views/microposts/_micropost.html.erb b/app/views/microposts/_micropost.html.erb index e32326e..dbe88a5 100644 --- a/app/views/microposts/_micropost.html.erb +++ b/app/views/microposts/_micropost.html.erb @@ -1,5 +1,13 @@