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? %> +
Design method | +Case study | +Discussion | +User | +Content | ++ | + | + |
---|---|---|---|---|---|---|---|
<%= 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?' } %> | +
<%= 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