Displaying 20 results from an estimated 20000 matches similar to: "Where and how to store app wide settings variables?"
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
2006 Aug 17
2
validates_length_of with char field
I am new to ruby/rails and am having a problem with validates_length_of.
It seems to work fine on a varchar field, but when I try it on a char
field the extra characters are silently truncated and the message
appears that the record was successfully updated.
How can I get my app to produce my error message instead? I''ve tried
various variations, but here''s one of my tries:
2012 Aug 14
3
validates_format_of :message not working, validates_length_of :message is working
I''m using validates_format_of and the validation I want to do works, but I
can''t get an error message to be displayed if the data is invalid:
validates_format_of :mobile, :with => /\A[\+0-9]+\Z/, :message => " - Wrong"
I have another validation some where else that does display the error
message: " - Name is too long"
validates_length_of :name,
2005 May 29
0
validates_length_of && validates_presence_of: Duplicate error messages?
validates_presence_of :login , :on => :create, :message => "Please
enter a login."
validates_length_of :login, :within => 3..40, :message => "Login must
be a minimum of 3 characters."
Right now if the login field is left blank, both these errors get
thrown. I assume that setting a conditional for the first one if the
second one is thrown, something like
2007 Mar 29
4
validates_length_of not working with :if ?
Hello,
I''m trying to cut down the errors if the guy already getting the empty
nickname, so he doesn''t get anything about the nickname is short.
validates_presence_of :nickname
This below is not working ?
validates_length_of :nickname, :within => 4..40, :if => Proc.new {
|user| user.nickname.length > 1 }
nor this one below?
validates_length_of :nickname, :within
2006 Feb 09
0
Validations with conditions (:if)
Hello all.
I have a users table (it has three columns: name, password, active) and
I want to validate it''s name column only if the active column is set to
true. To do this I use the :if statement in all my validations, but it
doesn''t work. I''ve tried many ways to do this (using Symbols, Proc''s or
methods) and nothing works (using Symbols doesn''t
2005 Jul 07
3
NameError Exception
Ruby/Rails n00b here so go easy on me...
I''ve been wracking my brain trying to figure out what is wrong here.
I''ve checked all my models for the appropriate belongs_to, has_many,
etc. I''ve checked to make sure I''m using singular and plurals in the
right spot. I''ve checked my syntax around all my "within"''s and nothing
seems to fix
2011 Feb 28
1
(2.3.5) removing validations
Today I tried to remove (actually overwrite) a validation from a model,
from within a plugin.
This was the original validation:
validates_length_of :login, :maximum => 30
This was the only code I could come up with to replace it:
def self.included(base)
base.class_eval do
@validate_callbacks.delete_if { |callback|
begin
# Sorry, only way to remove
2006 Jan 20
3
Is there a way to validate a model w/o saving it?
I have some code in my controller which looks like this:
if request.post? and @account.save and @user.save
...
end
and in my Account and User models I have many :validates, like so
account.rb
validates_presence_of :subdomain, :on => :create
validates_uniqueness_of :subdomain, :on => :create, :message => "is
already being used"
validates_exclusion_of
2008 Aug 01
0
Help with Access Control
Hi,
I am following the excellent tutorial http://www.railsforum.com/viewtopic.php?id=14216
(post 5) on how to implement an access control feature i.e. only a
friend is allowed to view a profile of a particular member. I am not
using the restful authentication plugin as the author is using to
implement the authentication feature (post 1) in the tutorial. All I
am interested in is the post 5
2006 Dec 29
2
update_attributes fails: ReadOnlyRecord
I''m trying to update a record, but it just stops with
"ActiveRecord::ReadOnlyRecord". I don''t understand why, because I never
wanted my model to be read only. Relevant code:
Controller:
def edit
@project = find_project
if request.post?
@project.update_attributes(params[:project])
if @project.save
flash[:message] = _(''Project was
2005 Dec 29
0
UTF-8 and validates_length_of
Hello,
according to
http://wiki.rubyonrails.com/rails/pages/HowToUseUnicodeStrings
Rails is not ready for UTF-8 in many places, e.g. the
validates_length_of method. However, I see UTF-8 used in many Rails
applications. So, hopefully, is the wiki page now out-of-date?
Cheers,
Nils
--
Posted via http://www.ruby-forum.com/.
2006 Jul 07
0
has_many relation handling
Hello,
please have a look at this:
My tables:
create_table :languages do |t|
t.column :name, :string, :limit => 3
t.column :title, :string, :limit => 30
end
create_table :categories do |t|
t.column :category_id, :integer (3.)
t.column :created_at, :timestamp
t.column :updated_at, :timestamp
end
create_table :categorytranslations, :id
2006 Jul 16
0
Problems with validates_lenght_of
I''m building a login system, and I want users to be able to update their
password, first name and last name after signing up. So, when signing up
password can''t be nil, and it must be between 6..20 characters long. However,
on update, the user can choose to leave the password field empty (but fill in
other stuff, like first name) and then I want the User model to not update
2006 Jul 21
1
Using "validates" in Model Question on Control Flow
I started with LoginGenerator and have evolved a nice little ACL model
that is perfect for my app. The user model has statements like the
following in the model file that control validation of some of the login
fields:
validates_length_of :login, :within => 3..40
validates_length_of :password, :within => 5..40
validates_presence_of :login, :password, :password_confirmation, :on =>
2006 Jun 21
0
Login Generator gotcha..
One for the archive:
Validation on a new password submission [/signup] was less than 30
characters [validates_length_of helper] but the resulting hash in the
database was more than 30 [c40] ? the result was that in a relation JOIN
that users the User model, the password *hash validates_length_of the
hash [and not the original textual password] which silently fails and
doesnt save the
2006 Jun 25
0
Using the database schema to help validate data
I started working on this in response to Dave Thomas'' keynote as
RailsConf 2006. This little patch will validate that your text fields
will fit into the database. Obviously this is just a start, and many
more validations could be added. Also, this code could probably be
extracted into a plugin instead of patch to ActiveRecord.
Index: test/validations_test.rb
2006 Mar 16
0
validating presence of a tag
Hi,
I''m using acts_as_taggable. I have a form that asks for a question and a tag
for that question, something like:
<% form_tag -%>
<%= text_area("question", "question_text") %>
<%= text_field("tag", "name") %>
<%= submit_tag %>
<% end_form_tag %>
The question is one model. Tag is another.
My problem is that I
2011 Mar 01
0
(2.3.5) removing validations
(sorry for misposting this to rubyonrails-core earlier)
Today I tried to remove (actually overwrite) a validation from a model,
from within a plugin.
This was the original validation:
validates_length_of :login, :maximum => 30
This was the only code I could come up with to replace it:
def self.included(base)
base.class_eval do
@validate_callbacks.delete_if { |callback|
2011 Apr 18
2
acts_as_commentable validations
Hi all,
I recently started back up with Rails and things are going well up until
now.
I''ve set up acts_as_commentable in my Post model and it''s working great.
Problem is users are able to create a "blank" comment. I''ve added the
following validations in the comment.rb file generated by
acts_as_commentable to limit the comment length:
[code]