search for: orderedhash

Displaying 14 results from an estimated 14 matches for "orderedhash".

2011 Jul 14
1
ActiveSupport::OrderedHash disappears?
I noticed that ActiveSupport::OrderedHash disappeared from the Rails API pages. Does it mean that it is going to be deprecated? I know that Hash is ordered in Ruby 1.9, but this subject seems controversial, and in my opinion the ordered hash in Ruby 1.9 should have been called OrderedHash (or SequentialHash), even if it be an alias of the...
2006 Apr 27
6
OrderedHash
Looks like I have skipped on this, but still - a couple of questions: 1) Why there suddenly is an OrderedHash in ActiveSupport? (this glaring omission from ruby core is present in many apps already) 2) Why it doesn''t match the semantics of Hash respectively? 3) Why it''s #nodoc ? -- Julian ''Julik'' Tarkhanov please send all personal mail to me at julik.nl
2010 Jun 25
0
[PATCH] ActiveSupport::OrderedHash#update Does Not Set Keys
Hi all, On versions of Ruby prior to 1.9, using update on an ActiveSupport::OrderedHash will not set the keys correctly. This means that it is not possible to iterate over the hash using each or get the array of keys. For example: hash = ActiveSupport::OrderedHash.new hash.update(:name => "Bob") # => #<OrderedHash {:name=>"Bob"}> ha...
2010 Jan 24
2
OrderedHash Rails 2.3.2
I understand that ActiveSupport::OrderedHash.new [[1,2]] does not work beginning with Rails 2.3. I am running Rails 2.3.2. One commentator suggested simply creating the instance without arguments and then sequentially adding each element as a separate step. I tried that. The hash gets populated just fine but it is not ordered. Can anyone...
2006 May 02
4
ordering after a inject
Hi, My results are getting out of order after I do the following command: count = result.inject({}) { |hsh, row| hsh[row[''name'']] = row[''count''].to_i; hsh } Why? Here are more specifics: My complete method is this (based off of acts_as_taggable code - not'' DHHs, but the original one): def self.sql_to_count_plays(lookback) sql =
2006 Jun 21
2
raw sql and columns order
Hi, I''ve a model with the following method: def self.run(sql) return connection.select_all(sql) end so, the value returned is an array of hashes... the problen is that the sql command: "select name, id from table" and select id,name from table" returns the columns in the same order (name, id). And in my view, I need to keep the order of the SQL command.
2010 Jan 20
4
Searching an array
Hi everyone! :) I''m currently accomplishing what I want, but I''d like to clean it up a bit. I''ve placed the following items in an array (please excuse my lack of proper syntax): @widgets = [1, red] [2, blue] [3, red] [4, blue] I''d like to learn a way to search through the @widgets variable an separate the widgets, so that I could have: @blue_widgets = [2,
2010 Jun 08
9
[Rails Heroku] Problem with saving object (on heroku hosting)
Hi All, I have some strange problem which appears only on heroku hosting 2.3.5 default stack (not on my local computer) I have some models. Here they are: class Contact < ActiveRecord::Base belongs_to :user belongs_to :type, :class_name => "ContactType", :foreign_key => "type_id" validates_presence_of :name, :on => :create, :message =>
2006 Jun 07
1
Calling find on AR class, order by association count?
I suspect that this is going to wind up trivial and I''m going to slap myself in the head... Suppose I have User and Comment AR classes. User has_many :comments, Comment belongs_to :user I want to do a User.find, which returns User objects in order of which user has the most comments. I suspect that this involves renaming the COUNT(*) results of a sub-select so that I can order by
2010 May 28
1
cookie has key/value pairs and lost order after JSON decode
If a cookie has several items, and is encoded as JSON text as the value of the cookie, the order is actually apparent in the cookie''s text But if JSON.decode is used: ActiveSupport::JSON.decode(cookies[''item_list'']) and the result is actually in a hash, then the ordering is lost... Is it true that if the original JSON object has an array of hashes (1 key and 1
2011 Dec 27
1
sub query issue with active record.
i can manage the MySQL queries into active record.but in some cases basically with sub-queries.i didn''t get the correct output. here when i trying to change the MySQL queries into active-record. *MySQL Query* *select count(*) from ( SELECT transactions.loyalty_id FROM transactions JOIN loyalties ON (transactions.loyalty_id = loyalties.id) where loyalties.created_at >
2010 Jan 27
4
Better way to count Active Record Data?
I am trying to get hourly counts of orders between different price ranges from my database. I''m thinking there has got to be a better way than looping through each record and checking if the created_at time fits between hour 1, 2, 3, 4, etc of the day and then returning the count. Currently I am displaying just a total of the days sales that are between different dollar amounts this
2007 Sep 19
49
plugin dependencies
Hello all, The topic of plugin dependencies has come up before and it doesn''t seem to have been addressed by core or core doesn''t seem to think it''s an issue. I''ve looked at the current edge code and don''t see anything new, so if I''ve missed something *please* let me know. The following article makes mention of a require_plugin
2009 Apr 07
12
Problem with MYSQL after re-installing rails
Hey all- Re-installed OSX yesterday and with it, Ruby and Rails Now when I try to run db:migrate I get the error message: "!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. Rake aborted! no such file to load -- mysql" So, I try sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql And get: