adding featured tags list to debate form
This commit is contained in:
@@ -18,9 +18,11 @@ class DebatesController < ApplicationController
|
||||
|
||||
def new
|
||||
@debate = Debate.new
|
||||
load_featured_tags
|
||||
end
|
||||
|
||||
def edit
|
||||
load_featured_tags
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -29,13 +31,18 @@ class DebatesController < ApplicationController
|
||||
if @debate.save_with_captcha
|
||||
redirect_to @debate, notice: t('flash.actions.create.notice', resource_name: 'Debate')
|
||||
else
|
||||
load_featured_tags
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@debate.update(debate_params)
|
||||
respond_with @debate
|
||||
if @debate.update(debate_params)
|
||||
redirect_to @debate, notice: t('flash.actions.update.notice', resource_name: 'Debate')
|
||||
else
|
||||
load_featured_tags
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def vote
|
||||
@@ -53,4 +60,8 @@ class DebatesController < ApplicationController
|
||||
params.require(:debate).permit(:title, :description, :tag_list, :terms_of_service, :captcha, :captcha_key)
|
||||
end
|
||||
|
||||
def load_featured_tags
|
||||
@featured_tags = ActsAsTaggableOn::Tag.where(featured: true)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
<div class="small-12 column">
|
||||
<%= f.label :tag_list, t("debates.form.tags_label") %>
|
||||
<span class="note"><%= t("debates.form.tags_instructions") %></span>
|
||||
<span class="tags">
|
||||
<% @featured_tags.each do |tag| %>
|
||||
<a><%= tag.name %></a>
|
||||
<% end %>
|
||||
</span>
|
||||
<%= f.text_field :tag_list, value: @debate.tag_list.to_s %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -49,7 +49,10 @@ en:
|
||||
debate_text: Ellaborate your opinion
|
||||
text_instructions: "Explain your opinion, go into details, tell us what's the purpose of your idea"
|
||||
tags_label: Topics
|
||||
tags_instructions: Comma separated
|
||||
tags_instructions: >
|
||||
Tag this idea. You can choose among our proposals on the list or add any other tag you want by
|
||||
writing them separated by ";" and then pressing "enter".
|
||||
Some suggestions:
|
||||
accept_terms: I accept the privacy policy and the legal terms
|
||||
show:
|
||||
back_link: Back
|
||||
|
||||
@@ -49,7 +49,10 @@ es:
|
||||
debate_text: Describe tu opinión
|
||||
text_instructions: "Explica con todo el detalle que puedas y de una manera sencilla la idea y que crees que conseguiríamos con ella"
|
||||
tags_label: Temas
|
||||
tags_instructions: Separados por comas
|
||||
tags_instructions: >
|
||||
Etiqueta esta idea. Puedes elegir entre nuestras propuestas o introducir las que desees.
|
||||
Para ello solo tienes que escribir las etiquetas que desees separadas por ";" y pulsar "intro".
|
||||
Algunas recomendaciones:
|
||||
accept_terms: Acepto la política de privacidad y el aviso legal
|
||||
show:
|
||||
back_link: Volver
|
||||
|
||||
Reference in New Issue
Block a user