search for: each_value

Displaying 20 results from an estimated 22 matches for "each_value".

2006 Apr 18
6
Help with Forms
...:index parameter as explained here >> http://api.rubyonrails.com/classes/ActionView/Helpers/FormHelper.html. My question is: How do I find all the records in the asset table that have the tracking_id that was entered in the text field? In my controller Im doing this: params[:asset].each_value do |prod| records = Asset.find_all_by_tracking_id(prod) end However, this gives the error: ---------------------------------------------------------------------------- RuntimeError: ERROR C22P02 Minvalid input syntax for integer: "--- - tracking_id - "2202045"" Fnumu...
2006 Apr 04
5
How to implement tag clouds using plugin?
The code on http://blog.craz8.com/articles/2005/10/28/acts_as_taggable-is-a-cool-piece-of-code is based on the acts_as_taggable gem,anybody has done that using the acts_as_taggable plugin?thanks! btw:the code above uses the tag_count method,which is defined in the gem: def tags_count(options = {}) options = {:order => ''count DESC''}.merge(options)
2006 Mar 23
1
Multiple file uploads
...nd pick only those that have a file attached. Selecting only one file in the form, the paramters look simple: "image"=>{"file_1"=>#<File:/tmp/CGI344.4>, "file_2"=>"", "file_3"=>""}, so I tried this: params[:image].each_value do |incomming_file| unless incoming_file.empty? #do file processing end end However, this is still causing the empty fields (file_2, file_3 etc) to be processed, which raises all sorts of errors as the File.methods are not available of course. I tried .nil? and various other tests bu...
2008 Jan 18
2
NameError when using alias_method -- but method exists?
...d in the YAML module. Following along with the PickAxe example of making old methods do new things, I try this in irb: >> module YAML >> alias_method :orig_load_f, :load_file >> def load_file(*args) >> contents = orig_load_f(*args) >> contents.symbolize_keys.each_value {|v| v.symbolize_keys } >> end >> end But after that last ''end'', irb explodes, saying: NameError: undefined method `load_file'' for module `YAML'' from (irb):2:in `alias_method'' from (irb):2 But, continuing in irb: >&gt...
2006 Jan 18
22
Creating multiple child objects from the same form
...uestion_id end class Question < ActiveRecord::Base validates_presence_of :question has_many :answers end ############ question controller def create @question = Question.new(params[:question]) if @question.save logger.debug(@question.inspect) params[:question_answer].each_value do |answer| @question.answers << Answer.new(:answer => answer) end flash[:notice] = ''Question was successfully created.'' redirect_to :action => ''list'' else render :action => ''new'' end end...
2007 Mar 18
2
mongrel timing out
...uby/gems/1.8/gems/activerecord-1.15.3 /lib/active_record/connection_adapters/abstract/connection_spe cification.rb:109:in `verify_active_connections!'' /usr/local/lib/ruby/gems/1.8/gems/activerecord- 1.15.3 /lib/active_record/connection_adapters/abstract/connection_spe cification.rb:108:in `each_value'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_spe cification.rb:108:in `verify_active_connections!'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:111:in `prepare_application'' /usr/local/...
2006 Jun 02
4
Creating an array of params
I''ve got a bunch of text fields that I''d like to access as an array. The code looks like this: <%= text_field_tag "people[0][entry]" %> <%= text_field_tag "people[1][entry]" %> <%= text_field_tag "people[2][entry]" %> So when I submit the form, I''d like to be able to use it like params[:people].each {|p| p[:entry]}
2006 Mar 08
19
Creating multiple rows with one form
Hello. I''ve been trying this out for the past two days and I can''t seem to get it. I''m going to have a page where you can upload x amount of images at once. Lets say 10 images need to be uploaded, all with a caption. I''d like to have a browse button to choose the file, then the caption. Now, if I put 10 of them in one form, fill them all out and submit, I get
2006 Feb 03
7
how to add multiple new records from one form
I''m trying to provide our customers with a page where they can add up to 20 items to their cart in one form. The form simply has 20 rows with each row containing a text input for product code and a text input for quantity. I''ve tried having the controller create an array that has an object for each row by looping through something like: @new_items[1] = Cart.new and the
2006 Nov 04
0
arrayfields-3.6.0
...0 p list[:a] #=> 0 3.5.0: - added more hash-like methods - update - replace - invert 3.4.0: - added FieldedArray[] ctor - added methods to make Arrays with fields set behave more closely to Hashes - each_pair - each_key - each_value - fetch - has_key? - member? - key? - has_value? - value? - keys? - store - values 3.3.0: - added gemspec file - thnx Assaph Mehr - added FieldedArray proxy class which minimizes modifications to class Array and all...
2007 Mar 11
0
Good code?
...s = User.find(:all) render :action => ''new'' return false end @declarations_payers = params[:declarations_payers] @additional_persons = params[:additional_persons] #If there are payers, add them if @declarations_payers @declarations_payers.each_value { |user_id| #Add new object @declarations_payer = DeclarationsPayer.new #Set user_id variable (from post) @declarations_payer.user_id = user_id #Add aditional persons (from post) @declarations_payer.additional_persons = @additional_persons[user_id]...
2013 Dec 09
2
[PATCH] rework master-to-worker signaling to use a pipe
...@ class Unicorn::HttpServer def maintain_worker_count (off = WORKERS.size - worker_processes) == 0 and return off < 0 and return spawn_missing_workers - WORKERS.dup.each_pair { |wpid,w| - w.nr >= worker_processes and kill_worker(:QUIT, wpid) rescue nil - } + WORKERS.each_value { |w| w.nr >= worker_processes and w.soft_kill(:QUIT) } end # if we get any error, try to write something back to the client @@ -600,6 +596,7 @@ class Unicorn::HttpServer # traps for USR1, USR2, and HUP may be set in the after_fork Proc # by the user. def init_worker_process(wor...
2009 Jul 07
3
rake db:create:all error
Hi, I am getting this error when i execute rake db:create:all /opt/gitorious/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:569: [BUG] unknown type 0x22 (0xc given) any clues ? -Manish -- Posted via http://www.ruby-forum.com/.
2007 Jul 18
6
Yet another "mongrel dying daily" case
...b/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:109:in `verify_active_connections!'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:108:in `each_value'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:108:in `verify_active_connections!'' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:111:in `prepare_application'' /usr/local/...
2009 Jul 29
0
Problem uploading file to database mysql blob field
...> RAILS_ROOT: C:/InstantRails/rails_apps/redmine Application Trace | Framework Trace | Full Trace app/models/attachment.rb:56:in `file='' app/models/attachment.rb:60:in `file='' app/controllers/application.rb:183:in `attach_files'' app/controllers/application.rb:180:in `each_value'' app/controllers/application.rb:180:in `attach_files'' app/controllers/projects_controller.rb:195:in `add_file'' vendor/rails/activerecord/lib/active_record/base.rb:2372:in `send'' vendor/rails/activerecord/lib/active_record/base.rb:2372:in `attributes='' v...
2012 Jan 19
4
redirect_to with a hash instead of parameters
All, I have numerous places in my codebase like this: redirect_to :action => ''schedule_by_uid_and_run_date'', :uid => @schedule.first.train_uid, :year => @date.year, :month => @date.month, :day => @date.day I''d like to replace the :year, :month and :day parameters with a hash containing the three parameters. @date is an instance of a Date class,
2006 Mar 12
0
ERB and Builder template engines shouldn''t be so heavily wired in ActionView::Base
...by the file extension, instead pass the render_options to all registered handler''s template_exists? and check if some handler responds true. 3. File rendering would be processed this way (from ActionView::Base): def render_file( render_options={}, local_assigns={} ) @@template_handlers.each_value do |handler_class| if handler_class::template_exists?( render_options ) return handler_class.new( render_options, local_assigns ) end end raise ''no handler is able to render the file!'' end Inline rendering would be processed this way (from ActionView::Base): def render_...
2006 Mar 04
6
Determine if a value is an instance of String , or Array , or...
each loop inside a mixed hash I need to determine if the value is an instance of String How ? hash.each do |k,v| if v ( instance of ) String hash[ k ] = v.capitalize enf end
2010 May 10
1
Rails/mongrel/httpd issue - F13, rails 2.3.5
Hi, I have an issue with mongrel and rails. I add -B option(debug) to mongrel_rails in /etc/init.d/mongrel-rails but it didn't display more logs : http://ovirt.pastebin.com/N5v94cTu This is the page I get when I try to reach the ovirt web interface, I see the html tags (kerberos auth is working) : <html><body>You are being <a
2007 Jan 09
0
Production Mode with SCGI
...uby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:99:in `verify_active_connections!'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:98:in `each_value'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:98:in `verify_active_connections!'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:70:in `prepare_application'' c:/ruby/lib/...