Created
February 1, 2012 10:45
-
-
Save smooki/1716444 to your computer and use it in GitHub Desktop.
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
<div id="sondage-creation"> | |
<h2 class="title">Nouveau sondage</h2> | |
<%# form_for(:project, @project, :url => {:controller => "projects",:action => "update"}) %> | |
<%#= form_for([@event, @new_pool], :as => :poll , :url => {:controller => "pools", :action => "create"}, :validate => true) do |f| %> | |
<%= nested_form_for([@event, @new_pool], :as => :pool , | |
:url => {:controller => "pools", :action => "create"}, :validate => true) do |f| %> | |
<%= f.hidden_field :type %> | |
<%= f.error_messages %> | |
<fieldset> | |
<div class="left"> | |
<h3><%= f.label :name %></h3> | |
<%= f.text_field :name %> | |
<h3><%= t '.question' %></h3> | |
<%= f.text_area :question %> | |
<h3><%= t '.message' %></h3> | |
<%= f.text_area :message %> | |
</div> | |
<div class="right"> | |
<h3> | |
<%= t '.test_one_date' %> | |
<%= f.radio_button :type, YesNoDatePool.to_s %> | |
</h3> | |
<ul id="simpleChoiceContainer"> | |
<li><%= f.date_select :date %></li> | |
<!--<li><input name="" value="oui" type="text"></li>--> | |
<!--<li><input name="" value="non" type="text"></li>--> | |
</ul> | |
<h3> | |
<%= t '.test_multiple_date' %> | |
<%= f.radio_button :type, MultipleDatePool.to_s %> | |
</h3> | |
<ul id="multipleChoiceContainer"> | |
<% f.fields_for :choices do |choice| %> | |
<li> | |
<%= choice.date_select :date %> | |
<%= choice.link_to_remove "[x] remove" %> | |
</li> | |
<% end %> | |
<%= f.link_to_add "[+] ADD Date Choice", :choices %> | |
<!--<li><input name="" type="text"></li>--> | |
<!--<li><input name="" type="text"></li>--> | |
<!--<li><input name="" type="text"></li>--> | |
<!--<li><input name="" type="text"></li>--> | |
<!--<li><input name="" type="text"></li>--> | |
</ul> | |
</div> | |
</fieldset> | |
<div class="submit"> | |
<%= f.submit t '.validate' %> | |
<input value="Valider le sondage" type="submit"><br> | |
<a href="" class="button"><span>Illustre ton songage</span></a> | |
</div> | |
<% end %> | |
</div> |
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
class PoolsController < ApplicationController | |
def index | |
@event = Event.find params[:event_id] | |
@pools = @event.pools | |
end | |
def new | |
type = params[:type] if ["date", "text"].include?params[:type] | |
@event = Event.find params[:event_id] | |
#@new_pool = @event.pools.build(:user => current_user) | |
@new_pool = MultipleDatePool.new | |
if type == "date" | |
@new_pool.type = YesNoDatePool.to_s | |
#@new_pool.type = MultipleDatePool.to_s | |
foo = 0 | |
else | |
end | |
end | |
def create | |
@event = Event.find params[:event_id] | |
type = params[:pool][:type] | |
if type == YesNoDatePool.to_s | |
@new_pool = YesNoDatePool.create params[:pool] | |
end | |
if type == MultipleDatePool.to_s | |
@new_pool = MultipleDatePool.create params[:pool] | |
end | |
@new_pool.event = @event | |
@new_pool.user = current_user | |
if @new_pool.save | |
flash[:notice] = "Pool created" | |
redirect_to event_pools_path @event | |
else | |
flash[:error] = "Pool not created" | |
render :new | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment