Hello,
I''m setting a checkbox values based on the return of a model field
method. The way the method is set up - it only gets called when a
checkbox value is set.
Here''s the model code:
[code]
def within=(new_within)
@within = new_within == "1" || new_within == true || new_within
=''true'' || new_within == ''on''
end
[/code]
I would like that method to be called even when the checkbox is not set.
Thanks for any help anyone can provide.
Clem C
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Visit Indonesia 2008
2008-Feb-19 01:09 UTC
Re: Calling model methods even when the param is a not set
Could you provide me the check box script in view? you can put additional params in form_tag example : <% from_tag bla...bla.., :within => true %> ... <% end_from_tag %> I hope it can answer yours. it will be directly executed each time the form_tag is run. What do you want this ''def within'' is run for every time model is used or only in form_tag? *~*~*~*~*~**~*~*~*~*~* Reinhart Ariando YM : Booking2Heaven WEB : http://teapoci.blogspot.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Clem Rock
2008-Feb-19 17:20 UTC
Re: Calling model methods even when the param is a not set
Visit Indonesia 2008 wrote:> Could you provide me the check box script in view? > > you can put additional params in form_tag > > example : > > <% from_tag bla...bla.., :within => true %> > > ... > > <% end_from_tag %> > > I hope it can answer yours. it will be directly executed each time the > form_tag is run. What do you want this ''def within'' is run for every > time model is used or only in form_tag?Here''s the checkbox code: <input style="height:13px;" id="<%= search_obj %>_within" name="<%= search_obj %>[within]" type="checkbox" <%= !last_search[:within].to_s.blank? ? "checked=''true''" : "" %> value="1"/> Also, here''s the form_remote_tag code: <%= form_remote_tag(:url => {:controller => ''main'', :action => action}, :html => { :id => "#{search_obj}_form", :action => url_for(:controller => ''main'', :action => action) } ) %> I would like to have the def within to be run everytime the form_tag is called. I tried putting the :within => true in the form_remote_tag and had no results. Thanks again for your help.> *~*~*~*~*~**~*~*~*~*~* > Reinhart Ariando > YM : Booking2Heaven > WEB : http://teapoci.blogspot.com-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Clem Rock
2008-Feb-20 23:28 UTC
Re: Calling model methods even when the param is a not set
SHAMELESS BOOT!
Clem Rock wrote:
Visit Indonesia 2008 wrote:
Could you provide me the check box script in view?
you can put additional params in form_tag
example :
<% from_tag bla...bla.., :within => true %>
...
<% end_from_tag %>
I hope it can answer yours. it will be directly executed each time the
form_tag is run. What do you want this ''def within'' is run
for every
time model is used or only in form_tag?
Here''s the checkbox code:
<input style="height:13px;" id="<%= search_obj
%>_within" name="<%search_obj %>[within]"
type="checkbox" <%!last_search[:within].to_s.blank? ?
"checked=''true''" : "" %>
value="1"/>
Also, here''s the form_remote_tag code:
<%= form_remote_tag(:url => {:controller => ''main'',
:action => action},
:html => { :id => "#{search_obj}_form", :action =>
url_for(:controller
=> ''main'', :action => action) } ) %>
I would like to have the def within to be run everytime the form_tag is
called.
I tried putting the :within => true in the form_remote_tag and had no
results.
Thanks again for your help.
*~*~*~*~*~**~*~*~*~*~*
Reinhart Ariando
YM : Booking2Heaven
WEB : http://teapoci.blogspot.com
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---