Topic: so whats the difference between check_box_tag() and check_box()

I am still trying to get this to send right and i find
check_box_tag() and check_box()
Both are just sending text values,, I need it to send key values so I can group those keys and have the search search in those keys

Re: so whats the difference between check_box_tag() and check_box()

check_box is for use with a model object, and check_box_tag is for when you just need a plain ole checkbox that's not tied to a model.

checkboxes in general aren't made to handle multi-dimensional data, only plain strings.  If you need complex data, then you're going to have to come up with your own mechanism. For example if you need to store a key value pair, you could just pass it as a string   

<%= check_box_tag 'pair', 'key=value' %>

On the other end you'd have to manually parse it

key, value = params[:pair].split '='

Re: so whats the difference between check_box_tag() and check_box()

so what do I use then to do this basic simple Search filter tool ?

It's driving me bonkers now.. I sooo want to get over this hurdel and past this point in the development . I thought I was so close

Re: so whats the difference between check_box_tag() and check_box()

this is all I want to do....
http://img130.imageshack.us/img130/7478/filterssr8.jpg
http://railsforum.com/viewtopic.php?id=241

i'm going crazy with this ... sad

Re: so whats the difference between check_box_tag() and check_box()

I think this should work.

view

<%= check_box_tag 'filters[]', 'city' %>
<%= check_box_tag 'filters[]', 'state' %>
<%= check_box_tag 'filters[]', 'county' %>

controller
filters = params[:filters]
for filter in filters
  # do something with filter
end

Re: so whats the difference between check_box_tag() and check_box()

sorry just waking up, Will try this very soon thank you

Re: so whats the difference between check_box_tag() and check_box()

tinkering now

def fakesearch(city, state, county)
  if :city == 1
    city(here_here)
  else :city == 2
    nil
  end
end

Kinda getting it

def newa
  @findme = DiaryController.find(id)
 
  filters = params[:filters]
  for filter in filters
    # do something with filter
    find(:city)
    state_this :city => 'fish'
   
  end
end

though it's  now bit@ching that find is undefinded... I thought find was a given.... Hmm

Last edited by tripdragon (2006-08-18 10:57:23)

Re: so whats the difference between check_box_tag() and check_box()

You are calling "find" on the controller. Try calling it on the model. Also, I'm not certain what you are attempting to do in the filter loop with "find(:city)" and "state_this".

You will probably want to build your search conditions in the filter loop, then call Model.find(:all, :conditions => conditions) - using your own model of course.

Railscasts - Free Ruby on Rails Screencasts

Re: so whats the difference between check_box_tag() and check_box()

WOA! I was waaaaaay off
http://railsforum.com/viewtopic.php?id=357&p=2