Displaying 20 results from an estimated 32 matches for "validates_".
Did you mean:
validates
2006 Aug 10
0
Broken validates_* functions
Hi,
I''m trying to work my way through the agile book and I''m at the example
where I bring in form validation using the validates_presence_of methods and
so on.
The problem I am having is, my application completely ignores these
functions. Even though the methods are there, they don''t catch any empty
fields.
This is what I have, created with scaffold:
class Product < ActiveRecord::Base
validates_presence_of :tit...
2006 Sep 12
2
accessing validates_... , :message => 'something'
Hi,
i have a validates_something_of_something method in my User model...i
added a :message => "you need to abcd" to the validation method, but
when i try to access it through the <%= error_messages_for "user" %> it
doesn''t give me any output...
i was wondering whether there was a...
2005 Sep 25
2
Problem issue with belongs_tohas_one and error_message_on
...profile = Profile.new(params[:profile])
if request.post? and @user.save
end
end
So it saves into users and profile, but I''m still getting error if in
register.rhtml is <%= error_message_on("profile", "publicname") %>
And still doesn''t work all validates_* I''ve put into model profile.rb.
So sed, but after all this strugling with this still I''m in begining of work.
Please be kind to me and I beg You all the Railers for help
Best Greatings
2005 May 04
1
Conditional validations
...rking with the problem that Joe Hosteny has been talking
about on this list and on the tickets he''s posted
(http://dev.rubyonrails.com/ticket/1196) and have come up with a
tentative solution that I''d like to bring up here.
What if we use a "conditional" parameter in the validates_* methods?
Here''s how it would look like in practice:
class Movie < ActiveRecord::Base
def allowed_to_validate=(true_false)
@allowed_to_validate = true_false
end
def allowed_to_validate
@allowed_to_validate
end
protected
validates_length_of :title, :within => 1...
2006 Sep 27
2
how to get the message from validates_presence_of
hi,
I''ve a model with validates_*_of statements, but I have no idea how to
get the :message back, anyone has a clue? Thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk"...
2006 Feb 21
8
Validations continued
...client = Client.new(params[:client])
if @client.save!
flash[:notice] = ''Client was successfully created.''
redirect_to :action => ''list''
else
render :action => ''new''
end
end
Model # includes the following
validates_presence_of :first_name
protected
def validate
errors.add_on_empty %w(first_name)
end
And if I try to enter a new ''client'' missing the first name, it sends me
to trace error page but doesn''t capture it as it suggests in Agile book.
This is making me crazy...
2006 Apr 07
2
errors.add_to_base
What are the limitations on using:
errors.add_to_base
to display errors in views?
I have tried for days to add errors from my object.rb and they never get
displayed.
class Keyword < ActiveRecord::Base
validates_presence_of(:name, :message => "Name is required.")
validates_uniqueness_of(:name, :message => "This name is already in
use. Please try another.")
# counter_cache should be set to true, but it is broken!
acts_as_tree :order => "name", :counter_cac...
2006 Mar 13
32
DRY principle form validations
We are wondering how you''d validate a credit card number or a SSN
without writing Javascript and Ruby code.
Would it be through Rails'' AJAX support?
--
Posted via http://www.ruby-forum.com/.
2006 Jun 20
1
Possible to check if form field is required?
Hi list,
is it possible to check if form field will be required when form is
submitted (through validates_presence_of or some other validates_*
method)? I could do this manually but it doesn''t seems to me very DRY.
For example, I would like to be able to dynamically add asterisk with
some helper method if city is required here:
City*: <%= text_field ''accomodation'', '...
2006 Apr 13
0
Custom validation of form fields?
I have been looking at the many validates_* methods that we have
available and I am wondering is it possible to create a custom
validation method to be performed on a form field?
I have the following form (remote via ajax)
<%= form_remote_tag :url => {
:action => ''do_action'',
:id => @pid },...
2006 Aug 07
1
Override flash message - help
How can I modify the flash message that is displayed on a validates_*
check? I used the :message => "" parameter, but it still gives me an
annoying "Test : Please ensure you have entered the test message". I
wanted to get rid of the "Test: " and the above "6 errors prohibited
this table from being saved" I looked at the...
2006 Jan 26
21
pagination_links help
I want append custom query parameters to my pagination links, like
?page=1&foo=bar. I can''t quite figure out how to do this with the
pagination_links helper, although I believe the API says you should be
able to:
pagination_links(paginator, options={}, html_options={})
options are:
:params: any additional routing parameters for page URLs
Has anyone tried this?
thanks,
jeff
--
2006 Jun 16
2
RJS replaces JavaScript?
Hi All,
I am currently devleoping a Rails application and I need to do following as
part of client side operations,
1. HTML Form validations
2. AJAX
I am currently calling Javascript methods from views of my application; I
heard about RJS(Remote Javascripts) templates; are the replacing Javascript
altogether? can I use RJS for HTML Form validations and AJAX?
What I believe is that with RJS
2006 Mar 11
0
Ruby-GetText-Package-1.3.0
..."ja"(Japanese).
* Localization templates support.
* ActionController::Base.render_text is overrided to find
localized templates such as foo_ja.rhml, foo_ja_JP.rhtml.
* @params["lang"] is treated as cgi["lang"]
* Use N_() as localized messages of validates_* instead of _().
* Translates ActiveRecord::Column.human_name values automatically.
* Fix memory leak, other bugs.
Thanks to:
Albert Ramstedt, Yugui, drawnboy, Erkki Eilonen,
Nickolay Kolev, Kazuhiro NISHIYAMA and others.
*Note*
Now you need to use N_() as localized messages of validates_*...
2006 Jul 17
19
updating model
hello,
i am writing a simple user login system.
when registering a user account, i have two field:
password
password_confirmation
which are validated using
validates_presence_of
validates_confirmation_of
and these are then used to generate a password hash which is stored in
my database
when i want to update the record (without changing the password and
entering new values for password and password_confirmation), using the
update_attributes method, i am gett...
2007 May 19
3
form question
Suppose I have the following models/migrations:
class Car < ActiveRecord::Base
belongs_to :manufacturer
validates_presence_of :manufacturer
validates_association :manufacturer
end
class CreateCars < ActiveRecord::Migration
def self.up
create_table cars do |t|
t.column :name, :string
t.column :manufacturer_id, :integer
end
end
class Manufacturer < ActiveRecord::Base
has_many :cars...
2010 Feb 10
6
validation problems
Hi, there.
I have two validations in the model:
validates_numericality_of :value, :only_integer=>true,
:allow_blank=>true
validates_size_of :value, :is=>9, :message=>"must be 5-digit number",
:if=>Proc.new{|u| u.value.is_a?(Numeric)}
They work as expected except when the :value is character/string like
"a" "abc"...
2006 Apr 06
1
ActiveRecord subclassing best practises
Hi,
I want some of my models to inherit from a custom ActiveRecord::Base class. Where is the best place to put this custom subclass?
Actually, I just wanted to translate the default validate message so maybe there was a better thing to do than subclassing ActiveRecord::Base.
Thanks
Oscar
---------------------------------
How low will we go? Check out Yahoo! Messenger?s low PC-to-Phone
2006 Apr 26
0
Validation of params
As we all know you cannot trust anything you receive from the internet.
I am wondering what the correct RoR way is to solve this. For the model
there are various validates_* methods that you can use to ensure some
integrity of that part. That is good by itself. Though it would be nice
if setting these would also result in enforcement in the database backend
itself when supported. Here I am as much thinking of the relations as
has_many to ensure foreign keys are va...
2006 Apr 27
0
DRY validation
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all,
A few months ago someone posted a message about specifying validates_*
constraints on a per-attribute basis. I just created a small plugin
that
allows you to do this.
Here''s an example from one of my models:
class Country < ActiveRecord::Base
attribute :name, :string do |a|
a.validates_length :within => 1..48
a.validates_form...