Configurations des routes
Salut à tous !
J'ai un problème pour appeler ma méthode 'rechercher' à partir d'une vue. Rien ne se passe quand je clique sur le bouton de recherche. Pourtant quand j'affiche les routes de l'appli, l'url est là. Voici ce que j'ai dans mon fichier routes.rb:
Code:
1 2 3 4 5 6 7 8 9
|
map.connect 'clinical_studies/search' ,
:conditions => { :method => :get },
:controller => "clinical_studies" ,
:action => "search"
map.resources :clinical_studies do |clinical_study|
clinical_study.resources :clinical_study_countries
end |
dans ma page de recherche:
Code:
1 2 3 4 5 6 7 8 9 10 11
|
<% form_tag :action => 'search' do %>
<%= label_tag 'Stability Study search criteria:' %><br/>
<%= select_tag(:criteria,
options_for_select(ClinicalStudy::load_search_criterias,
params[:criteria])) %><br/>
<%= label_tag 'Key word:' %><br/>
<%= text_field_tag :value_to_match, 'Enter your search value here', :size =>80 %>
<% end %>
</fieldset>
<%= submit_tag "Search ..."%> |
dans le controlleur 'clinical_studies_controller':
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
def search
@criteria = params[:criteria]
@results = []
case @criteria
when ClinicalStudy.load_search_criterias[0]
#search by Pack Code
prd_packs = PrdPack.find_by_contents(params[:value_to_match])
redirect_to_index if prd_packs.blank?
prd_packs.each do |item|
pack_study = PackStudy.find_all_by_prd_pack_id(item.id)
@results << pack_study unless pack_study.nil?
end
when ClinicalStudy.load_search_criterias[1]
#search by Product Name
when ClinicalStudy.load_search_criterias[2]
#search by Strength
end
respond_to do |format|
format.html # search.html.erb
format.xml { render :xml => @results }
end
end |
Quelqu'un pourrais me dire où se trouve mon erreur??Merci!