On Monday, 11 August 2014 09:13:09 UTC-4, Javix wrote:
>
>
>
> On Monday, August 11, 2014 4:33:19 AM UTC+2, Ruby-Forum.com User wrote:
>>
>> Hi guys, 
>>
>> I have been trying to pick up rails and I am having trouble passing 
>> parameters through a link_to tag so as to retrieve records where there 
>> is a parameter match. 
>>
>> https://gist.github.com/Brayoni/3102c5dab7f76b1cee7b 
>>
>> Here is my view; 
>> <% @employees.each do |employee| %> 
>>
>>         <div class="name_list<%=cycle('odd', 'even')%>"><li> 
>>             <label><%= check_box_tag "retrieve_case[employee_ids]", 
>> employee.id, false,:class=>'right' %> 
>>                 <div class="att_list_names"><%= employee.first_name 
>> %></div> </label> 
>>         </li>  </div> 
>>     <% end %> 
>> </div> 
>>
>> <%= link_to "#{t('retrieve_case')}", {:controller => 
>> 'employee_indisciplines', :action => 'show_indisciplines', :employee.id 
>> => params[:retrieve_case]}, { :class => 'submit_button' }, :method => 
>> 'post' %> 
>>
>>
>> controller method; 
>>   def show_indisciplines 
>>     if request.post? 
>>       activated_ids = params[:retrieve_case][:employee_ids].collect 
>> {|employee_id| employee_id.to_i} 
>>
>>       if activated_ids 
>>         @employee_indiscipline = 
>> EmployeeIndiscipline.find_all_by_employee_id(params[:employee_id]) 
>>       end 
>>     end 
>>   end 
>>
>> -- 
>> Posted via http://www.ruby-forum.com/. 
>>
>
> *First*: you should not use *params *method in your views, it is only 
> available in a controller as a Hash to get values from views.
>

This is not true. `params` is available in the view. It's not always a good 
idea to *use* it there, but it's available.


Relating to the original question, the difficulty appears to be that the 
link isn't going to pick up the client-side checkboxes. This code:

:employee.id => params[:retrieve_case[]]}, { :class => 'submit_button' }, 
:method => 'post'

doesn't make any sense.

I'd recommend getting this form to work with a real submit button and 
without AJAX *before* complicating it.

Also: 2.3.5 is deeply, wildly out-of-date. At a minimum, you should upgrade 
to the last security release of 2.3.x as there are SEVERE issues in older 
versions.

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/b18e7016-9ad2-4592-8162-868cef9b5f51%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to