diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb new file mode 100644 index 0000000..197df82 --- /dev/null +++ b/app/controllers/tags_controller.rb @@ -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 = "#{content} " + if options[:removable] + tag = tag + '' + end + tag = tag + '' + tag.html_safe + end +end diff --git a/app/models/tag.rb b/app/models/tag.rb new file mode 100644 index 0000000..4f340ee --- /dev/null +++ b/app/models/tag.rb @@ -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 diff --git a/app/views/tags/_form.html.erb b/app/views/tags/_form.html.erb new file mode 100644 index 0000000..97e4883 --- /dev/null +++ b/app/views/tags/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_for(@tag) do |f| %> + <% if @tag.errors.any? %> +
+

<%= pluralize(@tag.errors.count, "error") %> prohibited this tag from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :design_method_id %>
+ <%= f.number_field :design_method_id %> +
+
+ <%= f.label :case_study_id %>
+ <%= f.number_field :case_study_id %> +
+
+ <%= f.label :discussion_id %>
+ <%= f.number_field :discussion_id %> +
+
+ <%= f.label :user_id %>
+ <%= f.number_field :user_id %> +
+
+ <%= f.label :content %>
+ <%= f.text_field :content %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/tags/edit.html.erb b/app/views/tags/edit.html.erb new file mode 100644 index 0000000..d248aa7 --- /dev/null +++ b/app/views/tags/edit.html.erb @@ -0,0 +1,6 @@ +

Editing tag

+ +<%= render 'form' %> + +<%= link_to 'Show', @tag %> | +<%= link_to 'Back', tags_path %> diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb new file mode 100644 index 0000000..7051147 --- /dev/null +++ b/app/views/tags/index.html.erb @@ -0,0 +1,35 @@ +

Listing tags

+ + + + + + + + + + + + + + + + + <% @tags.each do |tag| %> + + + + + + + + + + + <% end %> + +
Design methodCase studyDiscussionUserContent
<%= tag.design_method_id %><%= tag.case_study_id %><%= tag.discussion_id %><%= tag.user_id %><%= tag.content %><%= link_to 'Show', tag %><%= link_to 'Edit', edit_tag_path(tag) %><%= link_to 'Destroy', tag, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Tag', new_tag_path %> diff --git a/app/views/tags/new.html.erb b/app/views/tags/new.html.erb new file mode 100644 index 0000000..a555828 --- /dev/null +++ b/app/views/tags/new.html.erb @@ -0,0 +1,5 @@ +

New tag

+ +<%= render 'form' %> + +<%= link_to 'Back', tags_path %> diff --git a/app/views/tags/show.html.erb b/app/views/tags/show.html.erb new file mode 100644 index 0000000..9b508ea --- /dev/null +++ b/app/views/tags/show.html.erb @@ -0,0 +1,29 @@ +

<%= notice %>

+ +

+ Design method: + <%= @tag.design_method_id %> +

+ +

+ Case study: + <%= @tag.case_study_id %> +

+ +

+ Discussion: + <%= @tag.discussion_id %> +

+ +

+ User: + <%= @tag.user_id %> +

+ +

+ Content: + <%= @tag.content %> +

+ +<%= link_to 'Edit', edit_tag_path(@tag) %> | +<%= link_to 'Back', tags_path %> diff --git a/db/migrate/20140724015008_create_tags.rb b/db/migrate/20140724015008_create_tags.rb new file mode 100644 index 0000000..306d693 --- /dev/null +++ b/db/migrate/20140724015008_create_tags.rb @@ -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 diff --git a/public/no-image-available.png b/public/no-image-available.png new file mode 100644 index 0000000..fcfc6c9 Binary files /dev/null and b/public/no-image-available.png differ