Commit 544cb635
Changed files (4)
app
app/controllers/tutorials_controller.rb
@@ -19,6 +19,7 @@ class TutorialsController < ApplicationController
def create
@tutorial = current_user.tutorials.create(params[:tutorial])
+ current_user.tag(@tutorial, :with => params[:tutorial][:tags], :on => :tags)
respond_to do |format|
if @tutorial.save
format.html { redirect_to( '/tutorials' ) }
app/models/tutorial.rb
@@ -1,4 +1,5 @@
class Tutorial < ActiveRecord::Base
attr_accessible :description, :heading, :url, :image_url
belongs_to :user
+ acts_as_taggable
end
app/models/user.rb
@@ -10,6 +10,7 @@ class User < ActiveRecord::Base
has_many :authentications
has_and_belongs_to_many :interests, :join_table => 'users_interests', :uniq => true, :autosave => true
has_one :avatar
+ acts_as_tagger
def add_favorite( creation )
if self.already_likes(creation)
app/views/tutorials/_form.html.erb
@@ -38,6 +38,12 @@ $(function(){
<%= f.text_area :description, :class => "input-xlarge" %>
</div>
</div>
+ <div class="control-group">
+ <label for="tags" class="control-label">Tags:</label>
+ <div class="controls">
+ <input type="text" name="tutorial_tags" id="tags" value="" class="input-xlarge" />
+ </div>
+ </div>
<div class="form-actions">
<%= f.hidden_field :image_url %>
<button type="submit" class="btn btn-primary">Save changes</button>