search for: some_hash

Displaying 7 results from an estimated 7 matches for "some_hash".

Did you mean: name_hash
2006 Apr 13
2
Dynamic finder conditions
...rrassed of it so I won''t show it here). Is there already something like this out there? Also, is there any way I can make my code more Ruby-fied? Here''s what I have so far: --application.rb private #this could probably stand to be renamed def dynamic_conditions_from_hash(some_hash, model) model = Class.new(model) some_hash.delete_if { |key, value| not model.column_names.include? key } conditions_from_hash(some_hash) end def conditions_from_hash(some_hash) condition = '''' some_hash.each_pair {|key, value| if value.empty? n...
2006 Apr 16
3
variable variables?
Hi everyone, Does Ruby support variable variables like PHP (http://www.php.net/manual/en/language.variables.variable.php)? Or do I have to use eval, like some_hash.each_pair{|key, pair| eval "#{key} = #{value}" } Or is there some other way? I''m actually trying to figure this out in order to use ez_where to create its conditions from a hash, so if this isn''t even necessary could someone let me know? Thanks, Daniel
2006 May 09
6
Create checkboxes on page using contents of a hash
Hi all, I have a hash that is created in the index method of my controller. After it is created, the index.rhtml page is rendered. Upon this rendering I would like to create a check box for each key/value in the hash. The has is @recordsHash I have been trying varying stratagies like the one below, but to no avail. Do you have any ideas? Thanks for your help on this! html
2006 May 10
0
Boolean attributes - not so simple as I thought
...ause problems. I think the value of the attribute bool should always be accessed by bool? , but I need to get and set the value of the attributes in @attribs like this: get: @item.attribs.each {|a| puts @item.send(a)} set: @item.attribs.each {|a| @item.send(a.to_s + ''='', some_hash[a])} in the get part the method that gets called by send is @item.bool and not @item.bool?. Another issue is validation: should I use validates_inclusion_of :bool? , :in=>[false,true] or validates_inclusion_of :bool , :in=>[false,true] or validates_inclusion_of :bool , :in=>0...
2006 Aug 03
0
setting a session variable, :value and :session_path
Hello, I''m having some difficulty with using sessions. Basically, I''d like to be able to store a hash in an action: def action session[:details] = {:value => some_hash, :session_path => "/main"} end I''d like to be able to retrieve the hash in another action under the same "main" controller. I retrieve it by doing the following: def action2 hash = session[:details] v1 = hash[:name] # Problem is that this is null end I'...
2006 Aug 03
0
Setting session variables and expiration issue.
Hello, I''m having some difficulty with using sessions. Basically, I''d like to be able to store a hash in an action: def action session[:details] = {:value => some_hash, :session_path => "/main"} end I''d like to be able to retrieve the hash in another action under the same "main" controller. I retrieve it by doing the following: def action2 hash = session[:details] v1 = hash[:name] # Problem is that this is null end I'...
2015 Jan 08
4
RFC: getifexists() {was [Bug 16065] "exists" ...}
If we do add an argument to get(), then it should be named consistently with the ifnotfound argument of mget(). As mentioned, the possibility of a NULL value is problematic. One solution is a sentinel value that indicates an unbound value (like R_UnboundValue). But another idea (and one pretty similar to John's) is to follow the SYMSXP design at the C level, where there is a structure that