[Rails] Re: Hash mapping

2016-02-04 Thread John Sanderbeck
Got it. Just needed to put raw in front of the ruby call... Woo Hoo -- 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 unsubscribe from this group and stop receiving emails from it, send an e

[Rails] Re: Hash mapping

2016-02-04 Thread John Sanderbeck
I thought of a counter cache however one of the problems is I need to be able to query by a date range as well in some of my charts and a counter cache wouldn't work. I almost have it working however I am getting a " returned around each string which I believe is a javascript problem. My code

Re: [Rails] Re: Hash mapping

2016-02-04 Thread Jesse Knutsen
On 2/4/16 11:30 AM, John Sanderbeck wrote: I am trying to make this as efficient as possible which is why I was trying to do the group call. I was doing it in the Highchart definition which worked however it does many queries depending on how many initiatives there are. series: [{ name: "T

Re: [Rails] Re: Hash mapping

2016-02-04 Thread Colin Law
On 4 February 2016 at 16:30, John Sanderbeck wrote: > I am trying to make this as efficient as possible which is why I was > trying to do the group call. Why? > > I was doing it in the Highchart definition which worked however it does > many queries depending on how many initiatives there are. >

[Rails] Re: Hash mapping

2016-02-04 Thread John Sanderbeck
I am trying to make this as efficient as possible which is why I was trying to do the group call. I was doing it in the Highchart definition which worked however it does many queries depending on how many initiatives there are. series: [{ name: "Trainings", data: [ <% Initiative.all.each do

[Rails] Re: Hash Issue when looping through

2012-09-06 Thread Anthony Brushwood
This is solved! By adding flatten to the last loop... sub_area_option_item[:items][:option_item].flatten.each do |option_item| option_item[:name] <- THIS IS WHERE MY CODE BREAKS end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk"

[Rails] Re: hash assignment (1.9.2)

2011-09-08 Thread Frederick Cheung
On Sep 8, 12:44 pm, AppleII717 wrote: > Apparently ruby 1.9 allows a shortcut hash creation/assignment syntax > > h = {foo: "bar"} >  => {:foo=>"bar"} Yup, that was added to 1.9 > That line would generate one of the first of many errors you'd get if > you'd try to run the 1.9.2 application on a

[Rails] Re: Hash each where

2011-06-30 Thread Andrew Skegg
Sebastian writes: > > Thank you, > > that was exactly what I was looking for!!! > Further to the solution provided, if the data is coming from a database, then you can create some scopes to filter the information for you. It might be faster than looping through the array. -- You received

[Rails] Re: Hash each where

2011-06-30 Thread Sebastian
Thank you, that was exactly what I was looking for!!! On 30 Jun., 15:16, Paulo Muggler Moreira wrote: > John's answer. Also, the Ruby Hash > API > . > > > > > > > > On Thu, Jun 30, 2011 at 10:10, John Feminella wrote: > > only_new_entries = array

Re: [Rails] Re: Hash each where

2011-06-30 Thread Paulo Muggler Moreira
John's answer. Also, the Ruby Hash API . On Thu, Jun 30, 2011 at 10:10, John Feminella wrote: > only_new_entries = array_of_hashes.select { |h| h[:status] == "new" } > > ~ jf > -- > John Feminella > Principal Consultant, BitsBuilder > LI: http://ww

Re: [Rails] Re: Hash each where

2011-06-30 Thread John Feminella
only_new_entries = array_of_hashes.select { |h| h[:status] == "new" } ~ jf -- John Feminella Principal Consultant, BitsBuilder LI: http://www.linkedin.com/in/johnxf SO: http://stackoverflow.com/users/75170/ On Thu, Jun 30, 2011 at 09:07, Sebastian wrote: > Sorry, > > yes I have an array of has

[Rails] Re: Hash each where

2011-06-30 Thread Sebastian
Sorry, yes I have an array of hashes: hash = [{:name => "like", :status => "old"}, {:name => "this", :status => "new"}, {:name => "here", :status => "old"}] On 30 Jun., 14:31, Michael Pavling wrote: > On 30 June 2011 13:27, Sebastian wrote: > > > I have a hash that has a :status key. The v

Re: [Rails] Re: hash vs methods

2011-04-14 Thread Phil Crissman
On Thu, Apr 14, 2011 at 10:09 AM, John Merlino wrote: > Thanks for responses. So it's possible to call include? on a method? > > dom_class.include?("sortable") > Well, you aren't calling include? on the method, per se... you're calling include? on _whatever thing the method is returning_. So, i

[Rails] Re: hash vs methods

2011-04-14 Thread John Merlino
Thanks for responses. So it's possible to call include? on a method? dom_class.include?("sortable") -- 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 rubyonr

[Rails] Re: hash vs methods

2011-04-13 Thread Robert Walker
Philip Hallstrom wrote in post #992605: >> end > Using a method would let one override what happens when you assign to > that attribute.. say you need to do something magical with it... > validate it... convert it... set something else somewhere else... that > sort of thing... And, just as impor

Re: [Rails] Re: Hash objects not display properly

2011-02-25 Thread Colin Law
On 25 February 2011 13:58, Vijay Ra wrote: >>> <%=@q%> >>> >>> <%= @name.each do |h|%> >> >> You don't want <%= on the line above, that causes it to display the >> return value from the call.  You just want >> <% @name.each do |h| %> >> so that it will run the code but not display the result of t

[Rails] Re: Hash objects not display properly

2011-02-25 Thread Vijay Ra
>> <%=@q%> >> >> <%= @name.each do |h|%> > > You don't want <%= on the line above, that causes it to display the > return value from the call. You just want > <% @name.each do |h| %> > so that it will run the code but not display the result of this line. > > Colin Thanx u r god ;) -- Posted vi

Re: [Rails] Re: Hash to list fails

2011-02-15 Thread Colin Law
On 15 February 2011 18:26, Paul Bergstrom wrote: > Kedar Mhaswade wrote in post #981823: >> Or since only keys are needed, use each_key iterator. >> >> Also, I think ri should say that the "method" each "returns" the same >> Hash >> on which you called the method. >> >> -Kedar > > I actually need

Re: [Rails] Re: Hash to list fails

2011-02-15 Thread Michael Pavling
On 15 February 2011 19:54, Michael Pavling wrote: > You *probably* want something more like: >    <%=puts "#{h key} is #{h value}" %> Of course... without the "puts" :-/ <%= "#{h key} is #{h value}" %> -- You received this message because you are subscribed to the Google Groups "Ruby on Rai

Re: [Rails] Re: Hash to list fails

2011-02-15 Thread Michael Pavling
On 15 February 2011 18:26, Paul Bergstrom wrote: > Hmm. This should output a string in view but it doesn't: > > <% h = { "a" => 100, "b" => 200 } %> > <%= h.each {|key, value| puts "#{key} is #{value}" } %> It certainly won't do what you think it should As has already been pointed out, the .

Re: [Rails] Re: Hash to list fails

2011-02-15 Thread kedar mhaswade
On Tue, Feb 15, 2011 at 11:20 AM, Paul Bergstrom wrote: > It works as a ruby script. But not in Rails. Strange. > Or rather it works in Rails too. But does not do what you want. No wait, but it does do what you told it to do :-) -Kedar > > -- > Posted via http://www.ruby-forum.com/. > > -- > You

[Rails] Re: Hash to list fails

2011-02-15 Thread Paul Bergstrom
Colin Law wrote in post #981819: > On 15 February 2011 16:46, Paul Bergstrom wrote: >> Why does this output the same hash again (like hash.inspect) and not >> each key as I want? >> >> @myhash.each { |k,v| "" + k + "" } > > Because it is showing the return value of the method each, not what > you

[Rails] Re: Hash to list fails

2011-02-15 Thread Paul Bergstrom
It works as a ruby script. But not in Rails. Strange. -- 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@googlegroups.com. To unsubscribe from

Re: [Rails] Re: Hash to list fails

2011-02-15 Thread kedar mhaswade
On Tue, Feb 15, 2011 at 10:26 AM, Paul Bergstrom wrote: > Kedar Mhaswade wrote in post #981823: > > Or since only keys are needed, use each_key iterator. > > > > Also, I think ri should say that the "method" each "returns" the same > > Hash > > on which you called the method. > > > > -Kedar > > I

[Rails] Re: Hash to list fails

2011-02-15 Thread Paul Bergstrom
Kedar Mhaswade wrote in post #981823: > Or since only keys are needed, use each_key iterator. > > Also, I think ri should say that the "method" each "returns" the same > Hash > on which you called the method. > > -Kedar I actually need both. Hmm. This should output a string in view but it doesn't

Re: [Rails] Re: Hash or not a Hash?!

2010-07-16 Thread Dave Aronson
On Fri, Jul 16, 2010 at 09:02, Ram wrote: >  > :x=>"new_x" > > Here x is the key and "new_x" is the value. > >> :y=>{:x=>X.new} > > Here y is the key and another hash, {:x => X.new}, is the value. And > within this hash again, x is the key and X.new is the value. I think what's confusing him is t

[Rails] Re: Hash or not a Hash?!

2010-07-16 Thread Marnen Laibow-Koser
Abder-Rahman Ali wrote: > In Rails, we can see the following for example (They are separate here): > > :x=>"new_x" > > :y=>{:x=>X.new} > > From Ruby, I know that a hash has to be between { } But you are wrong. The braces can be omitted when there is no ambiguity. Any time you see =>, a Hash

[Rails] Re: Hash or not a Hash?!

2010-07-16 Thread Ram
> :x=>"new_x" Here x is the key and "new_x" is the value. > :y=>{:x=>X.new} Here y is the key and another hash, {:x => X.new}, is the value. And within this hash again, x is the key and X.new is the value. -- You received this message because you are subscribed to the Google Groups "Ruby on

[Rails] Re: Hash or not a Hash?!

2010-07-16 Thread Kirk Patrick
Abder-Rahman Ali wrote: > In Rails, we can see the following for example (They are separate here): > > :x=>"new_x" > > :y=>{:x=>X.new} > > From Ruby, I know that a hash has to be between { }, and the key is on > the left of => and the value to the right. > > But, in the above examples we are se

[Rails] Re: hash string to symbol

2010-04-05 Thread Srijith nair
Have you included the lib file in your class like include Hash or require 'hash.rb' If include is present then call the method like object.key_strings_to_symbols! If require is present then call the method like class_name = Student class_name.key_strings_to_symbols! Keep rocking! Chris Habgood

[Rails] Re: hash in controller is nil after submitting form

2010-03-18 Thread ES
ok, thanks! On Mar 18, 3:24 pm, Colin Law wrote: > On 18 March 2010 14:16, ES wrote: > > > hmmm, I'm totally new to this, what exactly is a helper used for?  For > > these kinds of constant-type things in a view? > > This is a reasonable introduction > -http://paulsturgess.co.uk/articles/show/4

Re: [Rails] Re: hash in controller is nil after submitting form

2010-03-18 Thread Colin Law
On 18 March 2010 14:16, ES wrote: > hmmm, I'm totally new to this, what exactly is a helper used for?  For > these kinds of constant-type things in a view? This is a reasonable introduction - http://paulsturgess.co.uk/articles/show/49-using-helper-methods-in-ruby-on-rails Colin -- You received

[Rails] Re: hash in controller is nil after submitting form

2010-03-18 Thread ES
hmmm, I'm totally new to this, what exactly is a helper used for? For these kinds of constant-type things in a view? On Mar 18, 3:08 pm, Colin Law wrote: > On 18 March 2010 13:53, ES wrote: > > > yes I am going through create, should I make the @columns hash a class > > variable or just repopul

Re: [Rails] Re: hash in controller is nil after submitting form

2010-03-18 Thread Colin Law
On 18 March 2010 13:53, ES wrote: > yes I am going through create, should I make the @columns hash a class > variable or just repopulate it in the create method? You could populate it in a before or after_filter on those actions. I have to say that the whole thing looks a bit odd. Are you sure

Re: [Rails] Re: hash in controller is nil after submitting form

2010-03-18 Thread Michael Pavling
On 18 March 2010 13:53, ES wrote: > yes I am going through create, should I make the @columns hash a class > variable or just repopulate it in the create method? You can do it however you like; you just need to make sure it's not nil ;-) Personally... I would make a decision based on the object

[Rails] Re: hash in controller is nil after submitting form

2010-03-18 Thread ES
yes I am going through create, should I make the @columns hash a class variable or just repopulate it in the create method? On Mar 18, 2:49 pm, Michael Pavling wrote: > On 18 March 2010 13:43, ES wrote: > > > the first time I load the page, the correct form displays but then > > when I click sub

[Rails] Re: Hash Problem .. + Urgent

2009-07-22 Thread David A. Black
Hi -- On Wed, 22 Jul 2009, Hemant Bhargava wrote: > > David A. Black wrote: >> Hi -- >> >> On Wed, 22 Jul 2009, Hemant Bhargava wrote: >> >>> So no solution .. is it .. ? >> >> Hashes in Ruby 1.9 are ordered by key insertion order. >> > > No i dont think so .. > The way i am inserting values in h

[Rails] Re: Hash Problem .. + Urgent

2009-07-22 Thread Hemant Bhargava
By d way champs .. where to write the code for require 'file' .. ? in layouts file or in same file .. or in controller or in model .. :) Conrad Taylor wrote: > 2009/7/22 Maurício Linhares > >> >> Hashes won't keep the insertion order in Ruby (or any other language, >> you'll usually have to us

[Rails] Re: Hash Problem .. + Urgent

2009-07-22 Thread Conrad Taylor
2009/7/22 Maurício Linhares > > Hashes won't keep the insertion order in Ruby (or any other language, > you'll usually have to use some kind of ordered hash). > > - > Maurício Linhares > http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr > > This isn't true because the insertion or

[Rails] Re: Hash Problem .. + Urgent

2009-07-22 Thread Hemant Bhargava
No i dont think so .. The way i am inserting values in hash is not d way i am getting these values .. David A. Black wrote: > Hi -- > > On Wed, 22 Jul 2009, Hemant Bhargava wrote: > >> So no solution .. is it .. ? > > Hashes in Ruby 1.9 are ordered by key insertion order. > > > David > > -

[Rails] Re: Hash Problem .. + Urgent

2009-07-22 Thread David A. Black
Hi -- On Wed, 22 Jul 2009, Hemant Bhargava wrote: > So no solution .. is it .. ? Hashes in Ruby 1.9 are ordered by key insertion order. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http

[Rails] Re: Hash Problem .. + Urgent

2009-07-22 Thread Maurício Linhares
http://loopkid.net/articles/2008/06/19/ordered-hashes-in-ruby-1-8 - Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Wed, Jul 22, 2009 at 9:29 AM, Hemant Bhargava wrote: > > But i remember i had done it in Perl .. So y not with ruby .. > > Hemant Bhargava

[Rails] Re: Hash Problem .. + Urgent

2009-07-22 Thread Hemant Bhargava
But i remember i had done it in Perl .. So y not with ruby .. Hemant Bhargava wrote: > So no solution .. is it .. ? > > > > Maurício Linhares wrote: >> Hashes won't keep the insertion order in Ruby (or any other language, >> you'll usually have to use some kind of ordered hash). >> >> - >> Ma

[Rails] Re: Hash Problem .. + Urgent

2009-07-22 Thread Hemant Bhargava
So no solution .. is it .. ? Maurício Linhares wrote: > Hashes won't keep the insertion order in Ruby (or any other language, > you'll usually have to use some kind of ordered hash). > > - > Maur�cio Linhares > http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr > > > > On Wed

[Rails] Re: Hash Problem .. + Urgent

2009-07-22 Thread Maurício Linhares
Hashes won't keep the insertion order in Ruby (or any other language, you'll usually have to use some kind of ordered hash). - Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Wed, Jul 22, 2009 at 9:23 AM, Hemant Bhargava wrote: > > Hi Guyz, > > Problem wi

[Rails] Re: Hash#merge in a controller

2009-05-10 Thread Julian Leviston
On 09/05/2009, at 9:58 PM, Alberto Santini wrote: > > Hi all! > > I have a Place model with a description attribute and a Service model > with an itinerary attribute. An itinerary is simply a string with > dash-seprated place descriptions. In my > services_controller.rb#create i > have the

[Rails] Re: Hash#merge in a controller

2009-05-09 Thread Alberto Santini
Mistery solved: that wasn't an Hash, but an HashWithIndifferentAccess, which #merge method doesn't accept any block :-) A .to_hash was sufficient :-) -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscri

[Rails] Re: Hash with key and value from ActiveRecord?

2009-03-25 Thread Heinz Strunk
Frederick Cheung wrote: > On Mar 25, 12:48�pm, Heinz Strunk > wrote: >> I just renamed @attributes but using 'health' instead of :health doesn't >> really help... > > There's also what Harold said - that hash method isn't doing what you > think it is. > > Fred Oh yeah, I overlooked his first p

[Rails] Re: Hash with key and value from ActiveRecord?

2009-03-25 Thread Frederick Cheung
On Mar 25, 12:48 pm, Heinz Strunk wrote: > I just renamed @attributes but using 'health' instead of :health doesn't > really help... There's also what Harold said - that hash method isn't doing what you think it is. Fred > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~---

[Rails] Re: Hash with key and value from ActiveRecord?

2009-03-25 Thread Heinz Strunk
I just renamed @attributes but using 'health' instead of :health doesn't really help... -- 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

[Rails] Re: Hash with key and value from ActiveRecord?

2009-03-25 Thread Harold
I actually don't get the OP's use of the hash method in this context: http://www.ruby-doc.org/core/classes/Array.html#M002182 It seems that it's just computing the hash, and the block passed is just being silently ignored... Heniz, using your code what's the output of @attributes.inspect and @att

[Rails] Re: Hash with key and value from ActiveRecord?

2009-03-25 Thread Frederick Cheung
On Mar 25, 11:46 am, Heinz Strunk wrote: > > @attributes = Attribute.find_all_by_character_id(@character).hash { > |u| [u.name, u.value] } > > and I would like to access it like > > @attributes[:health] > > but it doesn't work. Anyone can help me out with that? The keys of your hash are stri

[Rails] Re: Hash with key and value from ActiveRecord?

2009-03-25 Thread Harold
Try this: @attributes = Hash[*Attribute.find_all_by_character_id(@character).map { |a| [a.name, a.value] }.flatten] On Mar 25, 7:46 am, Heinz Strunk wrote: > Heya, > > I think I have thinking barrier. I just want a simple hash out of an > ActiveRecord. > > @attributes = Attribute.find_all_by_ch

[Rails] Re: Hash and Array

2009-02-24 Thread Frederick Cheung
On Feb 24, 3:52 am, Cyrus Dev wrote: > How can we create new objects from hashes ? > depends what kind of object you want to create. You can't call user.foo unless the user object has a foo method, and hashes don't. So create an instance of something that does have a foo method. Exactly what yo

[Rails] Re: Hash and Array

2009-02-23 Thread Cyrus Dev
How can we create new objects from hashes ? thanks .. Frederick Cheung wrote: > On 23 Feb 2009, at 08:48, Cyrus Dev wrote: > >> >> >> Yes fred >> >> I modify that array and hash that is my question.. >> >> Can I do that array like original like activ record array ? using any >> ruby or rails

[Rails] Re: Hash and Array

2009-02-23 Thread Frederick Cheung
On 23 Feb 2009, at 08:48, Cyrus Dev wrote: > > > Yes fred > > I modify that array and hash that is my question.. > > Can I do that array like original like activ record array ? using any > ruby or rails functions ? > Only if you create new objects from those hashes. Fred > thanks > > > Frederic

[Rails] Re: Hash and Array

2009-02-23 Thread Cyrus Dev
Yes fred I modify that array and hash that is my question.. Can I do that array like original like activ record array ? using any ruby or rails functions ? thanks Frederick Cheung wrote: > On Feb 21, 12:06�pm, Cyrus Dev > wrote: >> >> but after modifying this array with >> [{zip=>'d',{po =

[Rails] Re: Hash and Array

2009-02-21 Thread Miguel Regedor
I think there is some confusion in this conversation first of all: When you do that @users = User.find(:all) @users will be one array of users objects, and if user object answer to the method name you can do: @users.each do |u| puts u.name end and you will get all users names, But if you have

[Rails] Re: Hash and Array

2009-02-21 Thread Frederick Cheung
On Feb 21, 12:06 pm, Cyrus Dev wrote: > > but after modifying this array with > [{zip=>'d',{po => 'd'}}] > > then we can't use that directly in view it should some thing i have to > write in file file liek Well you've changed your array of active record objects into a hash or an array of hashe

[Rails] Re: Hash and Array

2009-02-21 Thread Cyrus Dev
No fred its not something like that this 2 types of array are total different it seems like that becuase if you write @users = User.find(:all) then in view file you can directly use that array with each loop @users.each do |c| c.title end but in my case in view file i write same code li

[Rails] Re: Hash and Array

2009-02-21 Thread Frederick Cheung
On Feb 21, 11:11 am, Cyrus Dev wrote: > thanks fred > > but in o/p > > when we use find method and print that object  it shows like that > > [#, #, #, #] That's probably because of exactly what I said. the default to_s/ inspect produces output like # but that's not legal html so it displays as

[Rails] Re: Hash and Array

2009-02-21 Thread Cyrus Dev
thanks fred but in o/p when we use find method and print that object it shows like that [#, #, #, #] but when i modify same array with some operations i got array like this [{"1"=>"75225", "2"=>"Sat"},{"1"=>"75225", "2"=>"Sat"}] now can I convert this as like above like active record type

[Rails] Re: Hash and Array

2009-02-21 Thread Frederick Cheung
On Feb 21, 11:00 am, Cyrus Dev wrote: > Hello all > > I have problem regarding hash and array > > I am retriving records using find method and then doing some operations > on it > and finally i got results like following > > [{"1"=>"75225", "2"=>"Sat"},{"1"=>"75225", "2"=>"Sat"}] > > which cont

[Rails] Re: Hash

2009-02-19 Thread Cyrus Dev
Thanks Rob But actually what I want to do here I have hash @restaurant now for each row I want to add diffinmiles and then filter some of rows from main hash with this new column add and then sort this new array based on diffin miles thanks Rob Biedenharn wrote: > On Feb 19, 2009, at 6:20 A

[Rails] Re: Hash

2009-02-19 Thread Rob Biedenharn
On Feb 19, 2009, at 6:20 AM, Cyrus Dev wrote: > Hi, > thanks > > but I have instance like this > > @restaurant= Restaurant.find(:all, :select => 'restaurants.*, 22 AS diffinmiles' > ) > > now for each i have to add one more column > > @restaurant.each_with_index do |c,index| > > @restaurant[in

[Rails] Re: Hash

2009-02-19 Thread Cyrus Dev
Hi, thanks but I have instance like this @restaurant= Restaurant.find(:all) now for each i have to add one more column @restaurant.each_with_index do |c,index| @restaurant[index]['diffinmiles'] =22 end but this is not work so that i have to not change in view file and i can direct acc

[Rails] Re: Hash

2009-02-19 Thread Frederick Cheung
On 19 Feb 2009, at 10:54, Cyrus Dev wrote: > > Hello all > > any one has idea how to add new column to existing hash array ? > by hash array do you mean an array of hashes ? > I have one hash instance like > @restaurant > > using each with index i m looping it and want to add new key and value >

[Rails] Re: Hash names with white spaces

2009-01-31 Thread Stefano Bonomi
Ok Tom, like you suggested, both params['first name'] and params[:'first name'] worked for me. Case solved. Thanks again Stefano -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

[Rails] Re: Hash names with white spaces

2009-01-31 Thread Stefano Bonomi
Hi Tom, first of all many thanks for your suggestion. I cannot migrate from the legacy database because it is still populated by an electronic PLC wich has only MS ACCESS (aargh!) or MS SQL connectors. The same for DB field names. They where defined five years ago and so I must live with them.

[Rails] Re: Hash names with white spaces

2009-01-31 Thread Thomas R. Koll
Hi Stefano, First of all, migrate your database. Legacy dbs suck and there's no reasons why to preserve them for too long. About your problem: Both params['first name'] and params[:'first name'] will work. ciao, tom -- Thomas R. "TomK32" Koll <> http://ananasblau.com just a geek trying to chan

[Rails] Re: Hash Sorting

2008-12-28 Thread Robby Russell
On Sat, Dec 27, 2008 at 8:28 AM, Jeremy Weiskotten wrote: > > Frederick Cheung wrote: >> On Dec 27, 4:18�pm, Jeremy Weiskotten > s.net> wrote: >>> hash = {} >>> key = [date, album_id] >>> hash[key] = value >>> >>> However, hashes are not sorted in Ruby 1.8. Rails 2.x has an OrderedHash >>> that ma

[Rails] Re: Hash Sorting

2008-12-27 Thread Jeremy Weiskotten
Frederick Cheung wrote: > On Dec 27, 4:18�pm, Jeremy Weiskotten s.net> wrote: >> hash = {} >> key = [date, album_id] >> hash[key] = value >> >> However, hashes are not sorted in Ruby 1.8. Rails 2.x has an OrderedHash >> that maintains the keys' nsertion order, but it's not efficient for >> lookup

[Rails] Re: Hash Sorting

2008-12-27 Thread Frederick Cheung
On Dec 27, 4:18 pm, Jeremy Weiskotten wrote: > hash = {} > key = [date, album_id] > hash[key] = value > > However, hashes are not sorted in Ruby 1.8. Rails 2.x has an OrderedHash > that maintains the keys' nsertion order, but it's not efficient for > lookup by key. If you only plan to use the h

[Rails] Re: Hash Sorting

2008-12-27 Thread Jeremy Weiskotten
Sunny Bogawat wrote: > Joshua Abbott wrote: >> Would you mind posting an example of the hash and an example of how you >> would like it sorted? >> >> Thanks, >> Josh >> http://iammrjoshua.com > > > say i have album id 233 and created date 12/09/2008 so my key should be > 12092008_233 in this

[Rails] Re: Hash Sorting

2008-12-26 Thread Sunny Bogawat
Joshua Abbott wrote: > Would you mind posting an example of the hash and an example of how you > would like it sorted? > > Thanks, > Josh > http://iammrjoshua.com say i have album id 233 and created date 12/09/2008 so my key should be 12092008_233 in this way? -- Posted via http://www.ruby-f

[Rails] Re: Hash Sorting

2008-12-25 Thread Joshua Abbott
Would you mind posting an example of the hash and an example of how you would like it sorted? Thanks, Josh http://iammrjoshua.com Sunny Bogawat wrote: > Hi, > > My hash contain key as a combination of album date created_at and > album_id and values are some photo object.and i need to sort this