similar to: validates... :if => Proc.new{...} does not find a method!

Displaying 20 results from an estimated 10000 matches similar to: "validates... :if => Proc.new{...} does not find a method!"

2006 Mar 24
1
Problems with before_validation
Hi all My visitors can create party organisator profiles, and I want assign them as the creators (the field creator_id in the organisators table references a member in the members table). To do that I tried it with before_validation: def before_validation creator = Member.find 1 end Sadly, this does not work. The validation validates_presence_of :creator_id Still tells me, that
2006 Jan 23
5
validates_uniqueness_of :username, :if => !self.new_record?
Hi all I want users to register on my page. To register, they only have to deliver an email and a password. Then a link with an activation token will be sent to them, and after clicking the link the user sees a page where he should fill in further details, means: a username. My model looks like this: class Member < ActiveRecord::Base validates_presence_of :username, :if =>
2006 Jul 04
1
LoginGenerator Problem
I am trying to make a barebones login system based on this example (which in turn is just standard RoR login) but when I enter a user name and password, it says the login is unsuccessful every time. I am not sure where I am going wrong. Here is all relevent information CREATE TABLE `users` ( `id` int(6) unsigned NOT NULL auto_increment, `login` varchar(20) NOT NULL default
2006 May 04
2
validates :on 2
Hello, I need to have this for :create and :login how do I do so validates_presence_of :login, :password, :password_confirmation, :user_name, :email, :on => :create I do need it to be off in a number of places though -- Posted via http://www.ruby-forum.com/.
2006 Jan 11
7
before_filter: how to give :except more than 1 value?
Hi all I have the following class: class MemberController < ApplicationController before_filter :authorize, :except => :index def index ... end Now I want to give the before_filter more than one :except argument. I tried :except => {:index, :login}, but this didn''t work. How can i accomplish this? Thanks a lot and have a nice day, Josh -- Posted via
2006 Apr 13
1
Model is not a class
I''m trying to specify a model in a controller, but rails gives me "Account is not a class", where Account is my model name ... This is my model: class Account < ActiveRecord::Base validates_presence_of :email, :email_confirmation, :username, :password, :password_confirmation validates_format_of :email, :with =>
2010 Oct 03
7
Rails 3, Validates, Custom Message
In Rails < 3, I could have a validation on model such as: validates_presence_of :name, :message => "some custom message here" If I try something similar in Rails 3: validates :name, :presence => true , :message => "some other custom message" obviously, it throws an exception. So the question is, in Rails 3, how to you give a simple custom message? Do I need to
2006 Aug 14
2
after_create is not being called
Hi all I have the following model: class PhotoGallery < ActiveRecord::Base attr_accessible :title, :description, :file_path, :title_photo_id has_many :photos, :dependent => :destroy belongs_to :title_photo, :class_name => ''Photo'', :foreign_key => ''title_photo_id'' validates_presence_of :title, :description, :file_path
2010 Sep 03
1
[PATCH] Adding some control over usages in the network creation/edition form
Signed-off-by: Simon COURTOIS <scourtois at linagora.com> --- src/app/controllers/usages_controller.rb | 13 +++++++ src/app/models/usage.rb | 2 +- src/app/services/usage_service.rb | 23 ++++++++++++ src/app/views/network/_form.rhtml | 56 +++++++++++++++++++++++++++++- src/config/routes.rb | 1 +
2006 Jul 14
2
Validation not executing on save - need help debugging
All, The validation on my object is not being triggered any more on the save action. I''m trying to debug it. In attempting to debug it, I''m trying to understand exactly what validates_presence_of does. Basically, I''m trying to see if for some reason, validates_presence_of doesn''t think my fields are blank now. I see from the API docs. that
2006 Jan 09
1
Saving an upload
I am creating a database for movies (films) and television shows (shows) that will have has_and_belongs_to_many relationships with the pictures table. CREATE TABLE screenshots ( id serial NOT NULL, filename character varying NOT NULL, content_type character varying NOT NULL, primary key (id) ); CREATE TABLE films ( id serial NOT NULL, name character varying NOT NULL,
2006 Mar 02
8
User Authentication
I''m trying to create a simple authentication system but am failing miserably. I''m (sort of) following the "Logging In" chapter of the Agile book. Ideally, any access to http://example.com/publish (and any of its subdirectories) should redirect to http:/example.com/publish/login when there is no valid session user_id. Code so far:
2012 Nov 17
2
Help needed for error in foreign key validation
I have two models bank and country. User should only associate a Bank with a country id present in the country table and I put validates presence of country to enforce it but i get error mysql2::Error: Unknown column ''countries.bank_id'' in ''where clause'': SELECT `countries`.* FROM `countries` WHERE `countries`.`bank_id` = 17 LIMIT 1 when updating the bank
2006 Jul 28
3
Forms: handle foreign keys (AssociationTypeMismatch)
Hi all I tried and tried and tried, but I still fail in creating a form with proper validation and stuff for foreign keys... So I''d really like to get some help here. I''m creating a booking site for DJ''s, and for every booking one can choose one of different countries: class Booking < ActiveRecord::Base validates_presence_of :country_id
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 Oct 09
2
has_many validation the Rails way
Okay, this is something I run into a lot and don''t really have a great solution. Here is a simple example: class Blog < ActiveRecord::Base has_many :posts validates_presence_of :name end class Post < ActiveRecord::Base belongs_to :blog validates_presence_of :name validates_presence_of :blog_id end Now, if I want to create a blog and post at the same time I
2008 Apr 30
4
what is .....undefined method `authenticate'
def login_submit if session[''user''] @logged_in = true else @logged_in = false end @user = User.new(params[''user'']) if session[''user''] = User.authenticate(params[''user''][''username''], params[''user''][''password'']) flash[:notice] =
2005 Oct 12
4
Validating 2 related models at once not working
Hello, I have a form that submits data to two related models/tables. One is Customer the other is Address. Validation for Customer works fine but not for the Address. Class Customer < ActiveRecord::Base has_one :address validates_presence_of :login, :password, :email validates_associated :address end Class Address < ActiveRecord::Base belongs_to :customer validates_presence_of
2006 Mar 25
3
validates_presence_of validation order?
I have a form with 3 fields: user_id, email and password. All 3 fields are required, so I have a "validates_presence_of :user_id, :email, :password" in my model. Works, but the validation errors show up in a different order than I specificed in the validates_presence_of statement. Is there a way to specify the order in which the validations (and corresponding error messages) should
2012 Aug 17
3
Rails doesn't validate create_model or build_model (has_one association)
I''ve got User has_one Shop. Rails is not validating when I tried create_shop or build_shop, neither in the browser nor the rails console. My code: class Shop < ActiveRecord::Base attr_protected :user_id belongs_to :user validates_presence_of :name, :primary_address, :city, :country_code, :currency end class ShopsController < ApplicationController before_filter