Skip to content

Instantly share code, notes, and snippets.

@rds
Forked from smooki/PoolsController.rb
Created January 31, 2012 16:48
Show Gist options
  • Save rds/1711524 to your computer and use it in GitHub Desktop.
Save rds/1711524 to your computer and use it in GitHub Desktop.
no association in params for create ...
class PoolsController < ApplicationController
def index
@event = Event.find params[:event_id]
@pools = @event.pools
end
def new
type = nil
type = params[:type] if ["date", "text"].include?params[:type]
@event = Event.find params[:event_id]
@new_pool = @event.pools.build(:user => current_user)
if type == "date"
#@yesno_pool = YesNoDatePool.new(:user => current_user, :event => @event)
#@multi_pool = MultipleDatePool.new(:user => current_user, :event => @event)
@new_pool.type = "YesNoDatePoll"
foo = 0
else
end
end
def create
@event = Event.find params[:event_id]
@pool = @event.pools.build params[:pool]
if @pool.save
flash[:notice] = "Pool created"
# redirect
else
flash[:error] = "Pool not created"
render :action => 'new'
end
end
end
<div id="sondage-creation">
<h2 class="title">Nouveau sondage (nommer)</h2>
<%#
new_event_pool GET (/:locale)/events/:event_id/pools/new(.:format)
{:locale=>/en|fr/, :action=>"new", :controller=>"pools"}
%>
<%# 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| %>
<%= form_for [@event, @new_pool], :validate => true do |f| %>
<%= f.hidden_field :user_id, @new_pool.user_id %>
<%= f.hidden_field :event_id, @new_pool.event_id %>
<fieldset>
<div class="left">
<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' %> <input name="questionType" value="simple" type="radio"></h3>-->
<!--<ul>-->
<!--<li><input name="" value="oui" type="text"></li>-->
<!--<li><input name="" value="non" type="text"></li>-->
<!--</ul>-->
<!--<h3><%#= t '.test_multiple_date' %> <input name="questionType" value="multiple" type="radio"></h3>-->
<!--<ul>-->
<!--<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment