Displaying 20 results from an estimated 1000 matches similar to: "Suggestion for improving value_to_boolean column conversion"
2010 Sep 02
1
ActiveRecord::ConnectionAdapters::Column value_to_boolean(value) does not return a boolean value.
value_to_boolean(value), does not always return a boolean value, only
when true.
150: def value_to_boolean(value)
151: if value.is_a?(String) && value.blank?
152: nil
153: else
154: TRUE_VALUES.include?(value)
155: end
156: end
If value is contained in TRUE_VALUES then it returns true(TrueClass).
But if value is
2006 Jun 24
6
convert 0, "0", "true", etc. to boolean
Hi,
is there a ruby / rails builtin function that converts
- 0 / 1
- "0" / "1"
- "yes" / "no"
- "true" / "false"
to a boolean?
cheers
peter
2005 Dec 27
3
myObject.send(column.name) from Agile Development book
I''m studying the Agile Development with Rails book. In the chapter that
first sets up the depot application (page 68), there is this bit of code
from a view:
<% for product in @products %>
<tr>
<% for column in Product.content_columns %>
<td><%=h product.send(column.name) %></td>
<% end %>
etc...
I am trying to absorb both Ruby and
2006 Feb 05
0
Enum patch for Rails
Hello!
I''ve modified ActiveRecord a bit to support enum columns. This is tested
only with MySQL, and maybe needs some changes for other adapters (if
they use another syntax or quoting style).
I believe this patch should be tested well, so I haven''t (yet) tried to
post it to the official Trac. It is also not solid-as-a-rock when it
comes to quoting ENUM values.
After
2006 Aug 19
7
Impossible to get stable?
I have concluded that it is impossible to get this background process
stable. I am out of ideas and could really use some help.
Here is what I have:
50 workers, just running an infinite loop that constantly calls save!
on a model. Keep in mind this is just for testing purposes. I catch
all exceptions and put them in the log.
I am tried setting allow_concurrency to true and false. Neither
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
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
2006 Aug 02
2
mangle ActiveRecord
Dear Gurus on Rails!
How do I change the behaviour of one method in
ActiveRecord::ConnectionAdapters::SchemaStatements ?
Full story:
I''d like to mangle
ActiveRecord::ConnectionAdapters::SchemaStatements
so when it creates a new sql table, it also (optionally) creates my
created_at, deleted, key_id, session_id etc columns that I use on basically
all tables.
It would not be DRY to repeat
2010 Oct 30
12
Anyone successfully ran JRuby 1.5.3, Rails 3, Tomcat6
Hi,
I''ve been trying to get JRuby 1.5.3 with Rails 3 to run on the Tomcat6
server with little success.
Has anyone been able to do this? If so, what issues did you have to
overcome to get this to work?
Also, is this a combination that you would recommend for a production
site, or is it all too new and untested?
The latest issue I''m stuck on right now is with the mysql-connector-
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
2006 May 02
4
useful bit of code (hopefully)
Hi,
I often find myself using bits of code like this inside ActiveRecord,
perhaps it''s useful for others, or others can improve on it:
###########
# fix user input before validating it
before_validation :sanitize_input
# santize input before actual validation is called
# this uses the little methods defined below
def sanitize_input
trim %w(adres postcode woonplaats email naam
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
2009 Sep 28
5
Multi-databases support
Hi,
While I was hacking ovirt-server, I have found that it's currently
restricted to Postgres DB. Even if I like postgres for serious work on a
server, I really prefer to hack/dev locally on a Sqlite or MySQL DB.
I have googled on rails in order to find a good answer for the "foreign
key problem" which forces OVirt to stay on pg. I have found a plugin on
this particular
2007 Nov 29
3
Strange Array behaviour
I''m having a strange thing when using the Enumerable extensions for
Rails:
Have a look at the following code:
class Invoice < ActiveRecord::Base
has_many :invoice_lines
def total
invoice_lines.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
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
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
2013 Sep 02
2
Why the string interpolation is not working inside the Nokogiri method `#search` ?
Why the string interpolation is not working inside the Nokogiri method
`#search` ?
require ''nokogiri''
doc = Nokogiri::HTML::Document.parse <<-eotl
<div>
<p>foo</p>
<p>foo</p>
<p>bar</p>
</div>
eotl
doc.class # => Nokogiri::HTML::Document
class Person
attr_accessor :name
end
ram = Person.new
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
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