-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class TagsController < InheritedResources::Base | ||
def create | ||
@tag = Tag.new(params[:tag]) | ||
|
||
|
||
if @tag.save | ||
# format.html { redirect_to @tag, notice: 'Design method was successfully created.' } | ||
# format.json { render json: @tag, status: :created, location: @tag } | ||
render :json => {:tag => tagify(@tag.content, {:removable => true})} | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @tag.errors, status: :unprocessable_entity } | ||
end | ||
|
||
end | ||
def tagify(id, content, options) | ||
tag = "<span class='tag-label label-gap'>#{content} " | ||
if options[:removable] | ||
tag = tag + '<span onclick="removeTag('+ (id.to_s) +', this);" class="glyphicon glyphicon-remove-circle"></span>' | ||
end | ||
tag = tag + '</span>' | ||
tag.html_safe | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Tag < ActiveRecord::Base | ||
attr_accessible :design_method_id, :case_study_id, :discussion_id, :user_id, :content | ||
# belongs_to :design_method | ||
# belongs_to :case_study | ||
# belongs_to :discussion | ||
# belongs_to :user | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<%= form_for(@tag) do |f| %> | ||
<% if @tag.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@tag.errors.count, "error") %> prohibited this tag from being saved:</h2> | ||
|
||
<ul> | ||
<% @tag.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :design_method_id %><br> | ||
<%= f.number_field :design_method_id %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :case_study_id %><br> | ||
<%= f.number_field :case_study_id %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :discussion_id %><br> | ||
<%= f.number_field :discussion_id %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :user_id %><br> | ||
<%= f.number_field :user_id %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :content %><br> | ||
<%= f.text_field :content %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing tag</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Show', @tag %> | | ||
<%= link_to 'Back', tags_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<h1>Listing tags</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Design method</th> | ||
<th>Case study</th> | ||
<th>Discussion</th> | ||
<th>User</th> | ||
<th>Content</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @tags.each do |tag| %> | ||
<tr> | ||
<td><%= tag.design_method_id %></td> | ||
<td><%= tag.case_study_id %></td> | ||
<td><%= tag.discussion_id %></td> | ||
<td><%= tag.user_id %></td> | ||
<td><%= tag.content %></td> | ||
<td><%= link_to 'Show', tag %></td> | ||
<td><%= link_to 'Edit', edit_tag_path(tag) %></td> | ||
<td><%= link_to 'Destroy', tag, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Tag', new_tag_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New tag</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Back', tags_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Design method:</strong> | ||
<%= @tag.design_method_id %> | ||
</p> | ||
|
||
<p> | ||
<strong>Case study:</strong> | ||
<%= @tag.case_study_id %> | ||
</p> | ||
|
||
<p> | ||
<strong>Discussion:</strong> | ||
<%= @tag.discussion_id %> | ||
</p> | ||
|
||
<p> | ||
<strong>User:</strong> | ||
<%= @tag.user_id %> | ||
</p> | ||
|
||
<p> | ||
<strong>Content:</strong> | ||
<%= @tag.content %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_tag_path(@tag) %> | | ||
<%= link_to 'Back', tags_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateTags < ActiveRecord::Migration | ||
def change | ||
create_table :tags do |t| | ||
t.integer :design_method_id | ||
t.integer :case_study_id | ||
t.integer :discussion_id | ||
t.integer :user_id | ||
t.string :content | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.