Skip to content

Instantly share code, notes, and snippets.

@smooki
Created February 1, 2012 18:53
Show Gist options
  • Save smooki/1718633 to your computer and use it in GitHub Desktop.
Save smooki/1718633 to your computer and use it in GitHub Desktop.
<section class="clearfix vote">
<%= form_for [@event, @pool], :url => respond_event_multiple_date_pool_path, :method => :put do |resp| %>
<ul>
<% @pool.choices.each do |choice| %>
<% end %>
<li><input type="radio" name="reponseSondage"> Réponse 1</li>
<li><input type="radio" name="reponseSondage"> Réponse 2</li>
<li><input type="radio" name="reponseSondage"> Réponse 3</li>
<li><input type="radio" name="reponseSondage"> Réponse 4</li>
<li><input type="radio" name="reponseSondage"> Réponse 5</li>
</ul>
<div class="submit">
<%= resp.submit t :validate %>
</div>
<% end %>
</section>
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]
if @type == "date"
@new_pool = MultipleDatePool.new
else
#@new_pool = Pool.new
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
def destroy
@event = Event.find(params[:event_id])
pool = Pool.find(params[:id])
if pool.destroy
flash[:notice] = "Pool destroyed"
redirect_to event_pools_path @event
end
end
def show
@event = Event.find(params[:event_id])
@pool = Object.const_get(Pool.find(params[:id]).type).find(params[:id])
end
def respond
@event = Event.find(params[:event_id])
@pool = Object.const_get(Pool.find(params[:id]).type).find(params[:id])
redirect_to [@event, @pool]
end
end
AppTizer::Application.routes.draw do
scope "(:locale)", :locale => /en|fr/ do
devise_for :users, :controllers => { :invitations => 'users/invitations',
:omniauth_callbacks => "users/omniauth_callbacks" } do
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
end
resources :users
resources :profiles do
member do
get 'edit_nickname'
end
end
resources :events do
resources :pools
resources :date_pools, :controller => :pools
resources :multiple_date_pools, :controller => :pools do
member do
put "respond"
end
end
resources :yes_no_date_pools, :controller => :pools
resources :kitties do
resources :kitty_donations
end
resources :buffets do
resources :buffet_drinks do
resources :buffet_drink_participations
end
resources :buffet_foods do
resources :buffet_food_participations
end
end
resources :galleries do
resources :gallery_images
end
resources :event_transports
member do
put 'update_invited'
get 'pools'
get 'infos'
get 'show_infos'
get 'edit_infos'
put 'update_infos'
put 'add_to_sleepers'
end
end
resources :event_invitations, :only => [:show] do
member do
put 'accept'
put 'refuse'
end
end
resources :friends
resources :communications
resources :messages
resources :comments
match '/welcome', :to => 'pages#welcome'
match '/dashboard', :to => 'pages#dashboard'
match '/messages', :to => 'messages#index'
match '/news', :to => 'communications#index'
match '/faq', :to => 'pages#faq'
match '/help', :to => 'helps#home'
match '/help/board', :to => 'helps#board'
match '/help/pool', :to => 'helps#pool'
match '/help/music', :to => 'helps#music'
match '/help/kitty', :to => 'helps#kitty'
match '/help/buffet', :to => 'helps#buffet'
match '/help/gallery', :to => 'helps#gallery'
match '/help/forum', :to => 'helps#forum'
end
match '/:locale' => 'pages#home'
root :to => 'pages#home'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment