search for: each_key

Displaying 20 results from an estimated 20 matches for "each_key".

Did you mean: cache_key
2006 Apr 21
1
HABTM - two lists
Does anyone know of a good example somewhere of an implemention for adding records with HABTM relations that have lots of possibilities. The best way that I''ve seen it done is where you have two lists (multiple select lists) where you have the possibilities on the left and ones you''ve added on the right with arrows to add and delete items. But the only ways I know how to
2009 Oct 12
2
yaml ?nodes? or nested maps
I want to iterate ?nodes? and ?leafs? for a yaml document: thufir@ARRAKIS:~/projects/rss$ thufir@ARRAKIS:~/projects/rss$ ruby user.rb user.rb:6: undefined method `[]'' for nil:NilClass (NoMethodError) from user.rb:5:in `each_key'' from user.rb:5 thufir@ARRAKIS:~/projects/rss$ thufir@ARRAKIS:~/projects/rss$ ruby user2.rb user2.rb:5: undefined method `[]'' for nil:NilClass (NoMethodError) thufir@ARRAKIS:~/projects/rss$ thufir@ARRAKIS:~/projects/rss$ nl user.rb 1 require ''yaml''...
2006 Apr 11
6
Reduce Number of Queries When Using ActiveRecord
I have a controller method called update_all that grabs parameters for about 30 form fields and saves them to the database. My current code looks to see if there is a string in params[] for each form field (two fields for each SelfEvaluationItem) and saves the updated self_evaluation_answer if a string is available. Since this is iterated code, I am almost certain that this generates 30 or so
2012 Oct 21
5
Error occured while evaluating nil
This is the code if !params[:ratings].nil? params[:ratings].each_key do |r| @selected_ratings << r @movies << Movie.where(''rating = :rating'', :rating => r) @sort = params[:sort] end elsif @selected_ratings = @all_ratings @movies = Movie.order(@sort) @sort = params[:sort] end This is the erro...
2012 Oct 21
2
check box tag binding between controller and the view
...en i run my app for the first time i want them all to be selected while for every next time i want it to have the last checked boxes checked. To do this, In my controller i have @all_ratings = Movie.all_ratings @selected_ratings = [] if !params[:ratings].nil? params[:ratings].each_key do |key| @selected_ratings << key end elsif @selected_ratings = @all_ratings end While my model looks something like class Movie < ActiveRecord::Base def self.all_ratings @all_rating = [''G'', ''PG'', '...
2007 Mar 01
2
FerretHash
...or fail term } reader.close return result end def values result=[] reader=Ferret::Index::IndexReader.new(@name) reader.max_doc.times{|n| result << reader[n][:value] unless reader.deleted? n } reader.close result end def each_key reader=Ferret::Index::IndexReader.new(@name) result=reader.terms(:key).extend(Enumerable).each{|term,freq| freq==1 or fail yield term } reader.close return self end def each each_key{|k| yield k,self[k] } end include Enumerable end if __FI...
2006 Nov 04
0
arrayfields-3.6.0
...#39;'] #=> 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...
2006 Jun 16
1
Is there a way of retrieving all req parameters without name
Is there a way of retrieving all the request parameters without name in the controller. Thanks & Regards, Asem -- Posted via http://www.ruby-forum.com/.
2006 Nov 24
0
Maybe a bug in Cookie:cookies
Hi man, Thank you very much for your good work. I think there may be a bug in Mechanize 0.6.3. Cookie:cookies (cookie.rb:L83 ) @jar[domain].each_key do |name| => if url.path =~ /^#{@jar[domain][name].path}/ if @jar[domain][name].expires.nil? cookies << @jar[domain][name] elsif Time.now < @jar[domain][name].expires cookies << @jar[domain][name]...
2006 Feb 12
6
Including another helper
I need to include another helper module apart from the normal two (ApplicationHelper and [controllername]Helper). The inclusion needs to be dynamic and based on external parameters (ie what helper that get included differ from request to request). Is it possible? How? /Marcus
2006 Jun 26
7
Using Rails to Generate static pages
Hi all, Has anyone ever thought about or implemented a way to use Rails to pull content from a database and actually *generate* static html pages from view templates? I want to throw a bunch of content into a db using rails and then put all my website templates into the views dir and write the files out with the content inside. The funny thing is that the html pages Rails normally outputs to
2006 Mar 03
3
dynamic queries
Is there an easy (and secure) way to search your database when you don''t know the number of parameters ahead of time? I can see doing it by concatenating together an sql query, but hopefully rails provides a more elegant way to do this with ActiveRecord without making a ginormous switch statement? For example, lets say my search form has 4 different input boxes. I only want the query
2006 Apr 08
7
text_field and arrays
Hi, I''m trying to do a bulk update on an array with the helper text_field. I''m trying to create an inputfield for every object in the array, but I''m not getting it right... example: class ClassA @arrayB[] end HTML (code with error): <% 0.upto(9) do |index| %> <%= text_field ''ClassA'', ''arrayB[index]'' %> non
2011 Sep 08
1
Magic Multi Connections gem + Rails 3.1
...tion from /Users/nopik/.rvm/gems/ruby-1.9.2-p180@christmas/gems/ activesupport-3.1.0/lib/active_support/core_ext/hash/keys.rb:44:in `block in assert_valid_keys'' from /Users/nopik/.rvm/gems/ruby-1.9.2-p180@christmas/gems/ activesupport-3.1.0/lib/active_support/core_ext/hash/keys.rb:43:in `each_key'' from /Users/nopik/.rvm/gems/ruby-1.9.2-p180@christmas/gems/ activesupport-3.1.0/lib/active_support/core_ext/hash/keys.rb:43:in `assert_valid_keys'' from /Users/nopik/.rvm/gems/ruby-1.9.2-p180@christmas/gems/ activerecord-3.1.0/lib/active_record/associations/builder/ association....
2009 Nov 26
9
ActionView::TemplateError (can't convert ActiveRecord::Error into String)
I cannot work out why this error is appearing. ActionView::TemplateError (can''t convert ActiveRecord::Error into String) on line #3 of app/views/button/_show_enquiry.html.erb: 1: <h1>Send us a message</h1> 2: <% remote_form_for :enquiry, :url => {:action => ''send_mail''} do | f| %> 3: <%= error_messages_for ''enquiry'',
2006 Jun 04
4
Multiple checkboxes
Please could someone suggest what might be wrong here. In my view I''m displaying a series of check boxes and when the form is submitted I want the controller to iterate over the values and contatenate them all into a string "1" if the box was checked and "0" if it wasn''t. I''m new to Ruby and Rails and I can''t seem to get any values out of
2007 Apr 10
8
ferret-0.11.4-mswin32 not compatible with Ruby1.8.4
Just a quick note for future reference - at least for me, ferret won''t work on Ruby 1.8.4. gem install ferret Successfully installed ferret-0.11.4-mswin32 ruby -v ruby 1.8.4 (2005-12-24) [i386-mswin32] irb irb(main):001:0> require ''ferret'' A windows error message box appears - ruby.exe - Entry Point Not Found The procedure entry point rb_w32_write could not be
2006 Jul 26
13
tweaking minimum word length?
Hi, Can Ferret be configured to change the minimum word length of what it indexes? Right now it seems to drop words 3 characters or less, but I''d like to include words going down to 2 characters. How would I do that? Francis
2013 Oct 13
24
exporting custom facts to puppet agents
Dear all, I have a custom fact, that reads a file and then generate the values dynamically based on the file content. It''s something like this: inFile = "/home/admin/OSs.txt" > gos = {} > > if File.exist?(inFile) > open(inFile, ''r'').each do |line| > next if line =~ /^\s*(#|$)/ > parts =
2007 Dec 06
43
Mocks? Really?
OK, so i''ve played a bit with mocks and mock_models in controller and view tests and i have a question. Is this statement really correct: "We highly recommend that you exploit the mock framework here rather than providing real model objects in order to keep the view specs isolated from changes to your models." (http://rspec.rubyforge.org/documentation/rails/writing/views.html