Hi Helpers,
                   I am new to Ruby in Rails and I have difficulty it 
passing the instance varaibles to the view. Earlier I was reading the 
values from the table directly in the view. Now I want to do that part in 
controller 
below is my code before changes
 
view....
<%= javascript_include_tag :defaults %>
<% form_tag( {:action => 'show'},{:method => :post}) %>
   <br><br>
   <b>Enter ComponentName
   <p>Search for a component to add or move </p>
   <% @complist = Components.find(:all, :select => 'DISTINCT 
component_name') %>
<%= select_tag "component_name",options_for_select([""]+@complist.map{|u| 
[u.component_name]}),:include_blank => true,:onchange => 
remote_function(:url => {:action => :setselectedcomp },:with => 
"'component_name='+value" ) %>
   <%= observe_field(:component_name,:controller => 
:comp_groups_controller, :url => {:action => 'select_groups'}, :update => 
:group_names, :with => "'component_name='+value" ) %>
<br>
 controller........
 
def setselectedcomp()
                $selected_comp = params["component_name"]
                puts "selected_comp: #{$selected_comp}"
                $selected_comp_id = Components.find(:all, :select => 
['component_id'], :condition => ["component_name = '#{$selected_comp}'"])
                puts "selectd_comp_id is #{$selected_comp_id}"
        end
def select_groups
                passing_comp = params["component_name"]
                puts "passing comp = #{passing_comp}"
                @belongstogroup = CompGroups.find(:all, :select => 
['group_name'], :conditions => ["component_name = '#{passing_comp}'"])
                belongstogroup.each do |num|
                 puts num.inspect
                end
                #return @belongstogroup
                render :partial => "select_groups"
        end
This is working perfectly fine
 
What I wanted to accomplish is 
1. in the select_tag I have added the  "include_blank=true" to allow user 
to add a value. it sisn't work for me. May i know what I did wrong
2. I am not getting the component_id value in the controller. Not sure what 
I did wrong
  $selected_comp_id = Components.find(:all, :select => ['component_id'], 
:condition => ["component_name = '#{$selected_comp}'"])
                puts "selectd_comp_id is #{$selected_comp_id}"
 
Appreciate your help on this.
 
Thanks
Sups

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/gBl2_ZaR0UwJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to