search for: value_before_type_cast

Displaying 18 results from an estimated 18 matches for "value_before_type_cast".

2006 Jun 02
3
Advice, why value_before_type_cast in FormHelper?
I am wondering why is in creating text fields with form_helper used value_before_type_cast instead of attribute value for field value? I set rails enviroment so date fields are in european format (dd.mm.yyyy) and would like to have same format in forms, but because of value_before_type_cast is called, form fields are filled with ''yyyy-mm-dd'' or timestamp integer, et...
2006 Mar 01
3
Form helpers and overloaded methods - help!
Can someone explain why form helpers appear to bypass any model methods I override for fields that are bound to database fields? It would be great if someone could tell me how to force the form field, etc to call the method instead of looking at the database / attributes collection. Let''s say I have a column called ''price'' in my database table "books"
2008 Sep 10
0
wrong number of arguments
...sers/ryan/Documents/Projects/store Application Trace | Framework Trace | Full Trace /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/ helpers/form_helper.rb:623:in `send'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/ helpers/form_helper.rb:623:in `value_before_type_cast'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/ helpers/form_helper.rb:612:in `value_before_type_cast'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_view/ helpers/form_helper.rb:535:in `to_input_field_tag'' /usr/local/lib/ruby/gems/1....
2006 Apr 06
3
Formating Float ActiveRecord attributes in text inputs
I have AMOUNT field that ActiveRecord maps to Float. Then I use text_field helper to generate text inputs on forms. Helper takes model object and attribute name and does not provide any formatting abilities, thus 2.40 is shown as 2.4 which is fine with floats but does not look good with currency. I have worked around this issue by adding amount_f attribute to the model that returns formatted
2007 Nov 06
2
Why is this view spec failing?
...ry/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_helper.rb:356:in `send'' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_helper.rb:356:in `value_before_type_cast'' *************** This is using the auto-created test it "should render new form" do render "/members/new.rhtml" response.should have_tag("form[action=?][method=post]", members_path) do end end Thanks for the help -- Posted via http://www.rub...
2006 Feb 21
2
ActiveRecord before_ callbacks question
...y/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1498:in `method_missing'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/form_helper.rb:253:in `send'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/form_helper.rb:253:in `value_before_type_cast'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/form_helper.rb:168:in `to_input_field_tag'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/form_helper.rb:76:in `text_field'' #{RAILS_ROOT}/app/views/admin/_form.rhtml:5 #{RAILS_...
2006 Jul 13
4
Does text_field go directly to attributes hash in AR object?
All, I''m having a hell of a time figuring out what is going on here. I''m trying to override one of my getters so that I can format it a certain way in my form. But I can''t seem to get text_field to call the appropriate method on my object. So here''s my getter: public def FAX fax = read_attribute(:FAX) puts fax
2006 Apr 09
6
Validating a DateTime
Hi, Does anyone know of a method to validate a DateTime field? I''ve looked at the validation docs and the validates_date / validates_time plug-in but I can''t find a method to validate a value in the format of yyyymmddhhmm. It seems like something that should exist already, so I''d just like to check before I attempt my own version... Cheers, Mark
2009 Dec 24
4
NoMethodError
...8/gems/activerecord-2.3.5/lib/active_record/ attribute_methods.rb:260:in `method_missing'' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/ form_helper.rb:845:in `send'' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/ form_helper.rb:845:in `value_before_type_cast'' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/ form_helper.rb:833:in `value_before_type_cast'' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/ form_helper.rb:754:in `to_input_field_tag'' /usr/lib/ruby/gems/1.8/gems/actionpack-2....
2006 Aug 19
5
Form helpers don''t work with facade columns?
Hello all, I''ve been trying to use a facade column but I notice that the form helpers don''t seem to respect the facade. In the following example I''m trying to story the prices as Integer values but present them to the user as decimals. class Product < ActiveRecord::Base def price=(new_price) write_attribute(:price, Float(new_price)*100) end def price
2006 May 18
3
populating array of text_fields from an array of model objects
I have in my view the following: <% 0.upto(@num_performances) do |idx| -%> <%= text_field ''performance'', ''city'', :index => idx, %> <%= text_field ''performance'', ''venue'', :index => idx, %> <% end -%> and in my controller I have: @performance = [Performance.new("city" =>
2006 Apr 18
1
''wrong number of arguments'' for text_field?
...1: <%= text_field ''inventory'', ''quantity'' %> /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/form_helper.rb:253:in `send'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/form_helper.rb:253:in `value_before_type_cast'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/form_helper.rb:168:in `to_input_field_tag'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/helpers/form_helper.rb:76:in `text_field'' #{RAILS_ROOT}/app/views/inventories/_for...
2007 Mar 09
0
InstanceTag#value changed in 1.2
In Rails 1.2, the interface to InstanceTag#value and #value_before_type_cast changed, and looking through the svn and Trac history, I can''t see why. It appears that every call to #value now passes the same argument (the result of the #object method), which just duplicates what the function did before it took an argument. The reason I bring this up is that the chan...
2007 Feb 28
1
Rails 1.2 Bug (?): to_text_area_tag
...t;cols"] = size options["rows"] = size else options["cols"], options["rows"] = size.split("x") end end content_tag("textarea", html_escape(options.delete(''value'') || value_before_type_cast(object)), options) end Now that I''ve gotten that out of the way, I must say that rails is AWESOME!! I''m able to develop real working apps so much quicker than I''ve ever done in php or java. Great stuff! Keep up the good work. Brendon Davidson -- Posted via ht...
2010 Jan 02
2
Underscore in a model's method causes it not to be called from the form helper
Hi, I''m using rails 2.3.5 and found following behavior, which I can''t explain. Maybe someone can. I have a model named ''Game''. Its database schema contains a field named ''pconfig_src''. I want to lazy load the pconfig_src value, so added following method to the model: def pconfig_src read_attribute(''pconfig_src'') ||
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
2008 Sep 01
3
basics questions on rails
Hello, I started to use rails few weeks ago, and I have got basic question about it. 1. There is a way to keep my form filled, after submit it (for example if I get errors) ? 2. I would like to create a ''tree'' with my datas like ''pages'' for example : a page has one children and belongs to a page. I added has_one and belongs_to to the model but it
2007 Jan 12
9
Nil object in E1 capture the order
I''m following the depot application in the rails bible Agile Web Development with Rails. In interation E1 NoMethodError in Admin#checkout Showing app/views/admin/checkout.rhtml where line #12 raised: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.include? Extracted source (around line #12):