Commit f7f1d9d3
Changed files (2)
app
controllers
views
tutorials
app/controllers/tutorials_controller.rb
@@ -19,10 +19,10 @@ class TutorialsController < ApplicationController
def create
@tutorial = current_user.tutorials.create(params[:tutorial])
- current_user.tag(@tutorial, :with => params[:tutorial][:tags], :on => :tags)
+ current_user.tag(@tutorial, :with => params[:tutorial_tags], :on => :tags)
respond_to do |format|
if @tutorial.save
- format.html { redirect_to( '/tutorials' ) }
+ format.html { redirect_to( '/tutorials', :notice => 'the tutorial was successfully added.' ) }
else
flash[:error] = @tutorial.errors.full_messages
format.html { render :action => "new" }
@@ -32,10 +32,10 @@ class TutorialsController < ApplicationController
def update
@tutorial = current_user.tutorials.find(params[:id])
-
+ current_user.tag(@tutorial, :with => params[:tutorial_tags], :on => :tags)
respond_to do |format|
if @tutorial.update_attributes(params[:tutorial])
- format.html { redirect_to(@tutorial, :notice => 'tutorial was successfully updated.') }
+ format.html { redirect_to(@tutorial, :notice => 'the tutorial was successfully updated.') }
else
format.html { render :action => "edit" }
end
app/views/tutorials/index.html.erb
@@ -18,6 +18,11 @@
<img src="<%= tutorial.image_url %>" />
<div class="caption">
<h3><%= tutorial.heading %> <small><%= tutorial.created_at.to_s :foomat %></small></h3>
+ <p>
+ <% tutorial.tags.each do |tag| -%>
+ <a href="tags/<%= tag.id %>"><span class="label"><%= tag.name %></span></a>
+ <% end -%>
+ </p>
<p><%= tutorial.description %></p>
<p><a class="btn btn-primary" href="<%= tutorial.url %>">Read</a> <a class="btn" href="<%= url_for tutorial %>">View</a></p>
</div>