similar to: Boolean attributes - not so simple as I thought

Displaying 20 results from an estimated 7000 matches similar to: "Boolean attributes - not so simple as I thought"

2006 Apr 11
4
Two versions of Rails on one PC
I want to have Rails 1.1 + Rails 1.0 on the same PC and be able to load my script with a different version each time. Is it possible? -- Posted via http://www.ruby-forum.com/.
2006 Jan 22
11
ActiveRecord find
Suppose I have three tables - authors, posts and topics. Every post have a topic and every topic has an author, so I have posts.topic_id and topic.author_id. When the author is guest (not registered), author_id is nil. I need to find all the posts (in one query) where every post have all the information of the topic and the auther, so if p is one of those posts I could get the name of the
2007 May 01
2
Problem validating boolean
Hi I''ve got a problem validating a boolean and I can''t see what the problem is. Here''s my model: class FinanceAgreement < ActiveRecord::Base belongs_to :asset validates_presence_of :finance_company validates_inclusion_of :balance, :in => 0.01..10_000_000 validates_inclusion_of :term, :in => 1..600 validates_numericality_of
2006 Jan 29
1
Accessing attributes
I have a name of an attribute and I need to get its value and set a new value for it: x1 = a.foo a.foo = x2 How do I do that if the name of the attribute ''foo'' is a var? I thought about doing this: attribute_name = ''foo'' x1 = a.attributes[attribute_name] a.attributes[attribute_name] = x2 but this is a bypass and I''m quite sure it would cause
2006 Apr 13
2
Dynamic finder conditions
Hi everyone, I''ve been working on some code which will take params and turn them into a WHERE clause for the :conditions option in finder methods. So far I''ve been able to do some very simple text matching. I''d like to be able to support ranges, and then go from there (in fact I''ve added code for date ranges but I''m embarrassed of it so I
2006 Apr 06
5
Using helper method of another model
I have a template that belongs to a certain model (model A). I need to call a helper method of a different model (model B). Then I need the helper method of B to call a helper method of model C. I tried using "include" and "require" and using namespaces, but I got "undefined method". What is the way to do it? -- Posted via http://www.ruby-forum.com/.
2005 Dec 23
6
Save using Update
Hi, I want to update an existing row in table "items" where items.id == 10 I tried this: item = Item.new item.f1 = ... item.f2 = ... ... item.id = 10 item.save I got an error Duplicate entry ... for key 10 : INSERT INTO items ... How do I make item.save to use UPDATE instead of INSERT? -- Posted via http://www.ruby-forum.com/.
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
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
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
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,
2006 May 26
4
Using ''validates_inclusion_of'' to validate foreign key
I seem to be missing something trying to use ''validates_inclusion_of'' to validate a foreign key and was hoping some one could piont out my mistake? The problem seems to be that Order.find_all.collect is not returning an array that contains the order_id, if I replace it with a hardcoded array everything works as expected. The model: class OrderItem < ActiveRecord::Base
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 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
2009 Jan 12
2
validates_presence_of fails with false boolean
This almost feels like a bug to me, since false is not nil. (i don''t think!) Using v_p_o on a boolean field fails validation if the field is passed with ''false''. It passes validation in the case of true. How can I validate _presence_of a boolean if it is submitted false? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~
2006 Apr 16
3
variable variables?
Hi everyone, Does Ruby support variable variables like PHP (http://www.php.net/manual/en/language.variables.variable.php)? Or do I have to use eval, like some_hash.each_pair{|key, pair| eval "#{key} = #{value}" } Or is there some other way? I''m actually trying to figure this out in order to use ez_where to create its conditions from a hash, so if this isn''t even
2006 Jan 11
0
Easy Question, I Think
I am just getting started with Rails, don''t know any Ruby, and don''t quite even get object oriented programming yet. I have tweaked my schema to The Rails Way and have generated a bit of scaffolding. I am trying to create a new Part, which references a PartName and a PartNumber. I can create a PartNumber on the fly, but the PartName has to exist. I have an inelegant solution
2016 Apr 26
1
winbindd becomes unresponsive on member server
Hello, I've been working on converting our OmniOS home directory member servers from Samba 3.6.25 to 4.3.8. For the first few hours after startup, everything is accessible and works as expected. Eventually, winbindd stops responding and smbd starts logging this error: domain_client_validate: Domain password server not available. At this point, authentications no longer work.
2006 Jan 12
0
Easy Question, I Think [re-post, sorry if dupe]
I am just getting started with Rails, don''t know any Ruby, and don''t quite even get object oriented programming yet. I have tweaked my schema to The Rails Way and have generated a bit of scaffolding. I am trying to create a new Part, which references a PartName and a PartNumber. I can create a PartNumber on the fly, but the PartName has to exist. I have an inelegant solution
2014 Feb 22
0
Validates inclusion of include fails at plugin.
Hello, MyModel.rb, TYPES = { "type1" => 1 , "type2" => 2, "type3" => 3 }.freeze validates_inclusion_of :my_type, :in => TYPES.keys --------------------------------------- MyModelPatch.rb, base.send(:remove_const, :TYPES) base._validators[:my_type].reject!{ |validator| validator if validator.is_a? ActiveModel::Validations::InclusionValidator } TYPES =