Displaying 20 results from an estimated 5000 matches similar to: "Valid options from hash"
2008 Nov 17
7
super global dummy method for gettext + rails 2.2
Hi,
since rails 2.2 doesn''t work with gettext anymore I decided to use a
gettext dummy method until the gettext team relases a working version
for rails 2.2. My application doesn''t need any i18n support right now
and this way i figured it would be very easy to integrate gettext
later. Just setup the plugin and go.
So I need a method called _ which is available in alle models,
2009 Jun 24
2
At my wits end ! Controlling passed in negative values from a form
Hi,
I am trying to validate a numeric value passed in from a form, which
is saved in a MySQL db as decimal(9,2)
Now problem is I need to ensure people don''t enter a form value like -.
003. In my validations, I have a validates_numericality_of check being
done. Furthermore, in validate method, I have a check using an if
statement such as :
((an_object[n].nil? or an_object[n] < 0) and
2006 Apr 08
4
Calling validates_inclusion_of out of default namespace
Hi,
I''m trying to run the "validates_inclusion_of" method in a before_save hook,
because the range is dependant on the related data. But I can''t figure out how
to call it. When calling it normally, it says it can''t find it.
I''ve tried several combinations like
"ActiveRecord::Validations.validates_inclusion_of", but I can''t seem to
2010 Jun 17
3
Can i use a hash on a collection_select? If don't, alternatives.
In my current application, i have food categories: mexican, home made,
japanese, ect
As these categories only have ID and name, no other attributes, i dont
want to create a table on the DB.
My first idea was to create a constant named FOOD_CATEGORIES, that is
has like:
FOOD_CATEGORIES = { 1=>''mexican'',
2=>''japanese'',
2009 Jul 31
6
Background daemon
It''s sending e-mail every hour, but I changed to sleep for a day, but
keep send the e-mail by hour. I don''t know what to do to send daily.
Could somebody help me?
thanks
############
# mailer.rb
###############
#!/usr/bin/env ruby
# You might want to change this
ENV["RAILS_ENV"] ||= "production"
require File.dirname(__FILE__) +
2006 Dec 15
4
Why won't Rails update my object attributes?
Here''s the issue: When I submit a form for updating,
@person.update_attributes doesn''t work. But the next nested clause for
updating images DOES work. How is that possible? However no matter
what I do the Person object will not change its attributes.
def edit
@person = Person.find(params[:id])
if request.post?
@person.update_attributes(params[:person])
2011 Feb 16
5
validates_inclusion_of with range on ruby 1.9
I found out today that Range#include? behaves differently on 1.9 than on 1.8 ( http://rhnh.net/2009/08/03/range-include-in-ruby-1-9 )
In order to deal with various edge cases, instead of just checking whether range.first <= value <= range.last, in ruby 1.9 include? steps through all the values in the range, checking for equality.
This is of course a lot slower - in my case, checking a date
2009 Nov 19
3
Log File Location
This may be a dumb question, but where can I see the error logs that
are usually displayed when unicorn is not daemonized? The
production.log file is empty in my app. Everything is currently
running as root.
2007 Jan 17
2
rake test and validates_inclusion_of
Hello,
I am just starting off with Rails, so I apologize in advance if there
is a terribly obvious answer to my problem. I''ve done some searching
and found similar problems to my own, but nothing which yielded a
solution.
I have a handful of models that I am unit testing. The tests for each
unit run successfully, but when I do a rake test, many of the tests
fail.
The assertions that
2010 Nov 20
6
unicorn 3.0.0 - disable rewindable input!
Changes:
Rewindable "rack.input" may be disabled via the
"rewindable_input false" directive in the configuration file.
This will violate Rack::Lint for Rack 1.x applications, but can
reduce I/O for applications that do not need a rewindable
input.
This release updates us to the Kgio 2.x series which should play
more nicely with other libraries and applications. There are
2007 Oct 13
4
Chapter 9
Hello,
I''m currently stunk on this issue for few days and I do not know how
to get it fixed.
The system always raises this error message :
order is closed
and here is my order.rb:
class Order < ActiveRecord::Base
include ActiveMerchant::Billing
before_validation :set_status
attr_protected :id, :customer_ip, :status, :error_message, :updated_at, :created_at
attr_accessor
2007 Mar 13
13
validates_inclusion_of disabling
Hello all.
I have a problem using validates_inclusion_of. I need to switch off some
validations during a migration period, is there a way?
I tried to use if, with a static method of one of my models, but the
behaviour is something strange
It seems that the static method should be in a string to be evaluated.
And the order of the elements in the if is counting...
:if => (:some_field
2007 May 23
4
Error when posting form
Trying to submit a form is resulting in the following error:
>> page = agent.submit(f, f.buttons.first)
query: "action=start&quick=Y&clientApp=0&clientID=MCO"
Net::HTTP::Post: /dealerApply/controller.jsp
using cookie:
JSESSIONID=GJ4NCvGJDTlrvrKsLw17hZ3FnlXFdVkvB5hh1jLkHKcH4Tn27371!-538794652
request-header: accept-language => en-us,en;q0.5
request-header: connection
2010 Jan 18
5
Re: puts & logger ... flush immediately
Marnen Laibow-Koser wrote:
> Ralph Shnelvar wrote:
>> newbie here ...
>>
>> I am tracing logic putting puts and logger.info calls in my code.
>>
>> I _think_ Rails is buffering output so that I can''t see what happens
>> until I close out webrick.
>
> But you are probably wrong. If you watch the log scroll by, you will
> generally see
2006 Feb 14
2
confusion with validates_inclusion_of
It appears that if your trying to use validates_inclusion_of for a
string value allow_nil wont work. For example, if I have an attribute
:year which is stored as a varchar then:
validates_inclusion_of :year, :in => "1980"..Time.now.year.to_s,
allow_nil=>true
will successfully validate the range but will not allow an empty input
field to be submitted. However, if :year is
2009 Jul 31
8
Would like include model association in to_xml
i have:
class Library << ActiveRecord::Base
has_many :books
end
class Book << ActiveRecord::Base
belongs_to :library
end
in my controller i have:
render :xml=> Library.find(:all).to_xml(:include=>books)
but, i would like put a condition in the books ( e.: pages >= 100 )
i would like to create a xml with all Libraries, but books with pages more
than 100)
How to
2010 Jan 03
9
ferret search in production
Hi there,
after recently deploying my app, I have noticed that the search
results are not being displayed...
When I look in my app, I also notice that the apps content (search
criterea) is not being indexed, so I dont have an index folder being
created.
I read on a google post that it may be that the ferret.yml server
isn''t started (or perhaps the content of this file are not right)
I
2007 Jan 18
2
Conditional validates_inclusion_of execution problem
All,
I have a field that I''m validating with validates_numericality_of on as
well as validates_inclusion_of, like so:
validates_numericality_of :number_of_owners,
:only_integer => true,
:message => ''must be a whole number''
validates_inclusion_of :number_of_owners,
:in => 1..3,
2007 Nov 06
2
Automatic marshalling with DB access
I have an item which has a hash for one of its fields. When i store it
in the db, i want to do a Marshal.dump of the hash, and similarly, do a
Marshal.load to turn the saved blob back into a hash again.
Is there a way to easily write this into the model, so that it happens
automatically when saving and loading a record?
thanks
max
--
Posted via http://www.ruby-forum.com/.
2011 Jan 14
4
Rails 3 / RSpec 2 use_transactional_fixtures and after_commit
We''re migrating a Rails 2.3.x application to Rails 3 and RSpec 2.x.
In Rails 2.3.x we were using
https://github.com/freelancing-god/after_commit to provide
after_commit functionality (now provided by Rails 3).
The plugin version of after_commit came with some helpers to make
testing with `use_transactional_fixtures = true` work.
From: https://github.com/freelancing-god/after_commit