Displaying 20 results from an estimated 130 matches for "to_a".
Did you mean:
o_a
2005 Dec 21
1
Are Ducks Hibernating ?
Dears,
Remembering last value in a select box don''t work for me as :
Controller :
@years=(1970..2005).to_a
Form:
<%= select_tag "year", options_for_select( (2001..2005).to_a,
@params[:year] ) %>
I had to write
<%= select_tag "year", options_for_select( (2001..2005).to_a,
@params[:year].to_i ) %>
for it works.
Not important, but I''m curious why..
Seasons Gre...
2009 Feb 27
0
Wierd to_a issue...
When I go to save a model, I get tons of these:
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
associations/association_proxy.rb:214: warning: default `to_a'' will be
obsolete
It looks like the warning is coming from method_missing!
Even stranger: the model saves correctly in the development
environment, but under certain conditions it does not save in the
production environment -- even if operating with an identical
database.
Any ideas of w...
2006 May 02
4
useful bit of code (hopefully)
...email
empty_to_nil %w(telefoon mobiel)
end
# pass in a list of fields whose values will be converted to nil
# you should only use these on objects that respond to empty?
# if the value is empty (this causes empty strings '''' to become nils)
def empty_to_nil(fields)
fields.to_a.each {|f| self[f] = nil if self[f].empty? }
end
# pass in a list of fields whose values will be trimmed
def trim(fields)
fields.to_a.each {|f| self[f].strip! }
end
# pass in a list of fields of this object that will be lowercased
# useful for accepting only unique emails
def downcase(fields)...
2007 Nov 20
9
Testing Models without fixtures
Hi,
I would like to test a sorting method that is in the user model, it''s
a class method called search.
What I would like to do is create 2 users and load the test database
with just those 2 users, so that I can call
User.search("john") and it would return those two users.
Not sure how to clear the test database and populate it just with
these 2 users for that specific
2006 Jul 28
6
STRFTIME() why is it not defined
I am trying to take the input from a field in wich the user enters a
date, and formatting it to my time format
if params[:gotcha] != ''''
gotc = params[:date].to_a
gotc.strftime("%m/%d/%y")
end
Yet I get this error:
NoMethodError in AddController#add
undefined method `strftime? for ["00000"]
What''s wrong. I''m positive this method is defined. What''s wrong with my
code? It''s so odd... Thanks for you...
2007 Nov 29
3
Strange Array behaviour
...s.sum(&:total)
end
end
class InvoiceLine < ActiveRecord::Base
belongs_to :invoice
def total
amount * price
end
end
Now, when calling invoice.total, I get wrong number of arguments (1 for
2) error, but when changing the the total method in Invoice to:
def total
invoice_lines.to_a.sum(&:total)
end
I''m not sure what causes the extra ''to_a'' to get the thing to work,
since invoice_lines.class also returns Array.
Anyone?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message bec...
2006 Feb 14
6
Creating a String of Random Characters and Numbers
I want to create a random string of length n that is made up of
characters and integers. Is there a function in rails or ruby that
allows me to do this?
Thank you my friend :-).
John Kopanas
http://www.kopanas.com
=====================================================================
http://www.soen.info - source of the freshest software engineering
information on the net
2009 Jan 21
1
AR to_xml problem with associations, Builder::XmlMarkup#to_a
When I do a to_xml(with a block) on an association of a model I got a
Builder::XmlMarkup#to_ary should return Array
Example that does not work.
@intervenant = Intervenant.find(params[:id])
output = @intervenant.to_xml( :skip_types => false, :dasherize =>
false) do |xml|
@intervenant.individu.to_xml( :builder => xml, :skip_instruct =>
true, :skip_types => fals...
2010 May 28
2
Suggestion for improving value_to_boolean column conversion
...g exception without knowing what
to do about them.
I will suggest to modify the existing implementation of
ActiveRecord::ConnectionAdapters::Column::value_to_boolean
to
ActiveRecord::ConnectionAdapters::Column.class_eval %q{
def self.value_to_boolean(value)
case value
when *TRUE_VALUES.to_a: true
when *FALSE_VALUES.to_a: false
else nil
end
end
}
First of all it simplifies the implementation (getting rid of initial
if. secondly it will at least result in nil if value is neither
recognised among TRUE_VALUES nor FALSE_VALUES
Jarl
--
You received this message because you...
2007 Dec 11
2
Patch 10463: has_many through using uniq does not honor order
Hi,
I''ve just submitted a patch for ActiveRecord;
http://dev.rubyonrails.org/ticket/10463
The patch includes new fixtures because I could not find a applicable
combination among the existing fixtures. I hope that''s okee.
Please +1 or comment it.
Thanks,
Remco
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
2013 Sep 02
2
Why the string interpolation is not working inside the Nokogiri method `#search` ?
...<p>foo</p>
<p>bar</p>
</div>
eotl
doc.class # => Nokogiri::HTML::Document
class Person
attr_accessor :name
end
ram = Person.new
ram.name="foo"
ram.name # => "foo"
doc.search(''//div/p[text()= "#{ram.name}"]'').to_a.size
# => 0
Where am I doing wrong ? please 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 unsubscribe from this group and stop receiving emails from it, send an email to...
2006 May 30
4
Hide parent element
I have some code that calls a partial to display one or more blocks
within a div tag. I want to have a close button (or cancel link) that
will fade that block but leave the others. Here is the code:
LINK:
<%= link_to_remote "Add Miscellaneous Link", :url => { :action =>
:add_iyc_link } %>
add_iyc_link.rjs:
page.insert_html :bottom, ''links'', :partial
2006 Mar 05
1
Storing a Selected Option in DB
...n a select_tag
helper method to use a Ruby range as a value. Now when the user makes
a selection from that list, I can''t figure out why the result doesn''t
get stored in the database.
The line in the _form looks like this:
<%= select_tag(:month, options_for_select((0..12).to_a)) %>
Pops up an option menu. There''s a column in the database called
"month." It''s defined as an integer. So I would expect Rails just to
take the user''s selection and stuff it into that column of the table.
But nothing gets placed there at all.
I'...
2013 Jul 25
0
Reported timing aren't thread-safe, are they?
...o]) would
be more friendly to such environments.
It isn''t a perfect solution as it won''t report correct timings (whatever
the correct definition would be) for some action like:
def some_action
render json: Hash[[:sections, :fields].zip [
Thread.start {Section.all.to_a},
Thread.start {Field.all.to_a},
].map &:value]
end
But in that case, I don''t even know how this should be reported ideally.
For instance, suppose Section.all.to_a takes 50ms from DB while
Field.all.to_a takes 70ms.
How would you explain an output like this?
Action c...
2006 Apr 10
9
Pagination with letter (A B C D ... Z)
Hi there,
Is there a neat and easy way to implement pagination with letters
rather than numbers eg :
A B C D ... Z
Rob
2007 Mar 29
7
object-oriented GUI design and event handling
I''m trying to setup a fairly simple GUI with Ruby to perform some SQL
queries. There are a few drop-down boxes where users can select
different options and then one button that when clicked should get the
text from each drop-down in order to perform the query. Once it gets the
result it should display it to a text control. The problem is I am not
sure how to actually reference each
2013 Mar 28
1
undefined method 'sanitize_limit' for #<ActiveRecord::Relation:0x2aaaad35d720>
...1.12/lib/active_record/relation/query_methods.rb:208:in
`build_arel''
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/query_methods.rb:196:in
`arel''
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation.rb:112:in
`to_a''
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:376:in
`find_first''
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:122:in
`first''
Error is occurred at the exec...
2007 Jun 19
3
another issue with highlighting
...ate if you could test and tell me if I''m the only one
having this problem.
TIA
<example>
require ''ferret''
include Ferret
# filling
index=Index::Index.new(:path => ''/tmp/test'')
chars1 = chars2 = chars3 = chars4 = ("a".."z").to_a + ("0".."9").to_a
chars2.concat(["-", "_", " "])
chars3 << " "
chars4 << "-"
chars5 = chars6 = ("0".."9").to_a
chars6 << "."
500.times do
z={}
t=""
1.upto(15+rand(10))...
2006 Mar 18
4
Accessing overridden method
I have two model classes:
class Item < ActiveRecord::Base
belongs_to :channel, :counter_cache => true
validates_presence_of :channel
end
class Channel < ActiveRecord::Base
has_many :items, :dependent => true
end
In the Channel controller I have variable channel.items, an Array of
Items. I would like to use the Array find method. However,
channel.items.find() is a Rails
2008 Jan 30
6
Schedule parser
Hi,
I was trying to schedule a worker to run during the midnight hour
like this:
:schedules:
:collector:
:process_something:
:trigger_args: 30 * 0 * * 2,3,4,5,6
When I try to start backgroundrb, the "collector" worker failed to
start up and I find this in backgroundrb_server.log:
/home/mengkuan/apps/testrailsapp/current/vendor/plugins/backgroundrb/