similar to: validate method doesn''t recognize another instance method

Displaying 20 results from an estimated 10000 matches similar to: "validate method doesn''t recognize another instance method"

2006 Jul 12
1
validate method not getting called?
Here''s a snippet of my model: validates_presence_of :from_name, :from_email, :reply_name, :reply_email, :eSubject protected def validate puts "Calling: #{target_list_ids}" errors.add_to_base("You must choose at least one target list for this job") if self.target_list_ids.nil? end It appears that the validates_presence_of are being called just fine,
2006 Jul 11
4
checkboxes with a has_many :through relation
All, I''m populating a view with checkboxes in a list. I want to be able to assign to my has_many relationship using the post values of these checkboxes. Essentially, I want to populate the relationship table which will create the correct join values in my model. Here is my check_box_tag code: <%= check_box_tag("@current_job[target_list_ids][]",
2006 Feb 18
6
Active Record errors value - Why doesn''t this work?
I''m creating an AR object in my controller and then attempting to add error messages to it: if (master_storeids.nil?) @item.errors.add_to_base ''No store is selected'' end This works without error but when it comes time for AR to add the record, it apparently initializes the errors because the message that I added does not cause the AR add to fail as you would
2006 Aug 26
3
order of saving/validating
Hi guys, I''m trying to do some validation on an image upload. Basically I have a model, Property, which has_many :property_images. I need to check that one image has been uploaded at least and so it was suggested I checked the number of images uploaded - @property.property_images.count > 0. Makes sense. I''ve added a validation on my Property model, like - def
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
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
2006 Jun 27
3
belongs_to <parent name>, :foreign_key modifier not working
All, I have two ActiveRecord objects. TargetList has_many Targets Targets belongs_to TargetList I''ve specified belongs_to :target_list, :foreign_key => ''DataSetID'' Queries generated by various methods in target_list do not seem to see the foreign_key name and keep trying to query my Target table using "target_list_id" (the default foreign
2006 May 02
1
Custom error messages
On a model I have the following simple validator: def validate unless name && name =~ /^\w+$/ errors.add_to_base("Name is missing") end end I would like to display a custom message on my views, without using the helper <%= error_messages_for "table" %> Where the messages from errors.add_to_base are stored and how to access them in the views? --
2006 Aug 16
7
Forward of moderated message
OK I know whats happening. Your while loop completes and calls kill on the worker before your task_progress controller method ever gets called> So the worker is deleted and when you try to access it from rails you get an error because there is no longer a worker at that job key. The kill method is meant to be used within a worker that you fire and forget. If you want to get the
2007 Oct 03
2
Providing HTML in an error message generated by validation
All, I have some validation that I''m doing in a model. As part of the error message, I would like to provide an HTML link. What is the best approach to handling this? APPROACH 1: One way is to include ActionView::Helpers::UrlHelper include ActionView::Helpers::TagHelper in my model so that I can use link_to to generate my link (obv. I could hard code HTML as well). But anyway that
2007 Sep 02
0
using database for validation
I''ve been playing around with the idea of using the database for model validation where possible (instead of duplicating that validation in rails). My first approach to this was to catch exceptions from save/ create and parse the errors, in my case from postgres, to turn them into something friendlier. Something like: def update create end def create begin super
2006 Aug 21
3
strange problem with system call
Hi, I am using backgroundrb to create a automated system of typo blogs.So, users can create new typo applications using web interface and all that jazz. Now..its working perfectly except one minor glitch. Since latest version of typo has a command called "typo", i simply use that command to install new typo app.And it works. def do_work(args) DIR =
2006 Feb 17
1
validate() with has_many association
I''m creating a simple portfolio site for a painter. I have a painting and an image model with following relationship: Painting has_many :images Image belongs_to :painting On the edit screen the user can edit the Painting data as well as upload pictures for a thumbnails and full size image. The Image model extracts filename, width, and height from the uploaded file, saves those
2006 Jun 22
4
ADVICE: Generating unique identifiers for later DB insertion
All, I have an ActiveRecord object that I need to be able to uniquely identify _before_ I actually save the object (I may not end up saving the object based on conditions). This is because I want to use the ID in another context (a file name in the filesystem). Depending on conditions, I may or may not need to do a lot of stuff between the time that I generate the object ID and actually
2006 Mar 13
2
Newbie: Can''t get file to upload
Since I can''t get the fancy upload progress thing to work, I thought that I would revert back to a regular file upload scenario. I have a very simple file upload form set up. It appears that my file parameter is coming into the controller as a string, not a file object. Here''s my view: <%= form_tag :action => ''save_HTML'', :multipart
2006 Jul 14
7
Form validation - keepin correct fields displayed on refresh
All, I''m finally doing my first real form in Rails - the model object that I''m entering information for has 8 validations so far. If I type in good values for all the fields but one, I get the pretty validation, and the nice field highlighting, but all of the fields are cleared, forcing me to retype all of that info. That is a big drag. Is there a standard way to get the
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
2006 Aug 09
6
How to change the error message easy way
validates_presence_of :fname results in the error message "Fname can''t be blank". What I want is "First Name can''t be blank". I could do this def validate errors.add_to_base("First Name can''t be blank") if fname.blank? end I find this clunky and I have to put everyrhing in the validate method. Is there an easy to get what I want. I
2006 Apr 21
11
Phone Numbers in Rails/MySQL
Is there any easy way to make a fancy looking form to take phone numbers. Something that looks like this: [ ] - [ ] - [ ] ext: [ ] Then when you submit it it''s combined into one string in the database. Optimally it would auto-switch from field-to-field after you fill each field. Has anyone seen anything like this in Rails? Thanks, Adam -- Posted via
2006 Jan 19
1
Model Validation & Floating Attributes
Hello all ! I have a model being validated that spits it''s error messages on the resulting page using: error_messages_for(:mymodel) .... Basic stuff. It''s working perfectly. Now, I have something else I want to check on the same page (that isn''t an attribute to the Model)... and am trying to add it using: @mymodel.errors.add_to_base("another error here")