app/controllers/knoth_controller.rb (revision eb9718d2968a) 1 class KnothController < ApplicationController 2 3 layout "application", :only => 'index' 4 include AuthenticatedSystem 5 before_filter :login_required, :only => [ :create, :delete, :edit, :update ] 6 7 def index 8 @kind = params[:kind] 9 @id = params[:id] 10 end 11 12 def list 13 @kind = params[:kind] 14 @sections = Section.find(:all, :conditions => { :kind => params[:kind] }, :order => 'name ASC') 15 end 16 17 def show 18 if params[:id].nil? 19 knos = Section.find(:all, :conditions => { :kind => params[:kind] }) 20 if knos.size < 1 21 render :text => 'Aucune association.' 22 return 23 end 24 kno = knos[rand(knos.size)] 25 else 26 kno = Section.find(params[:id]) 27 end 28 @article = kno.presentation 29 @secid = kno.id 30 end 31 32 def create 33 sect = Section.new(params[:knoth]) 34 if sect.save 35 flash.now[:notice] = params[:knoth][:name]+" ajouté" 36 art = sect.articles.create({ :kind => 'presentation', :name => sect.name }) 37 unless art.save 38 flash[:warning] = "Erreur [2], sérieux soucis !" 39 end 40 else 41 flash[:warning] = "Erreur [1], impossible !" 42 end 43 end 44 45 def edit 46 end 47 48 def delete 49 Section.find(params[:id]).destroy 50 # flash.now[:notice] = params[:id]+" supprimé" 51 # else 52 # flash.now[:warning] = "Erreur [3]" 53 # end 54 end 55 end app/views/knoth/delete.rjs (revision 11e20ea1c957) 1 update_page do |page| 2 page.visual_effect "fold", "li${params[:id]}" 3 end app/views/knoth/show.rhtml (revision 064a986849fb) 1
<%= link_to_remote "éditer", :url => { :action => 'edit', :id => @id, :kind => params[:kind] } %> 4 <%= link_to_remote "supprimer", :url => { :action => 'delete', :id => @secid, :kind => params[:kind] } %>
<% end -%> 5 6 <%= textilize(@article.content) %> 7 8