Displaying 20 results from an estimated 2000 matches similar to: "accessing associated models in a validate method"
2006 Mar 10
1
Validate fields and display errors from two models?
Hi,
I have here a problem I''ve been working at for a little while but I
can''t seem to get the error messages to appear correctly.
My form looks something like this for "ModelA":
[errors_for "modelA"]
[form for "modelA"]
[text "modelA" "fieldname1"]
[text "modelB" "fieldname2"]
[submit]
[/form]
The reason
2009 Oct 06
1
Problems Processing multiple form elements generated by javascript actions
Hi all,
After many days of struggling, I have a multi-model form with ajax
elements more or less working, but I''m hitting a wall with a few bugs
that I can''t figure out. Guidance would be very much appreciated.
I''m using the Ryan Bates technique from Advanced Rails recipes to
dynamically add and remove elements on a multi-model form.
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 =>
2010 Mar 24
3
mounting gfs partition hangs
Hi,
I have configured two machines for testing gfs filesystems. They are
attached to a iscsi device and centos versions are:
CentOS release 5.4 (Final)
Linux node1.fib.upc.es 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009
i686 i686 i386 GNU/Linux
The problem is if I try to mount a gfs partition it hangs.
[root at node2 ~]# cman_tool status
Version: 6.2.0
Config Version: 29
Cluster Name:
2006 Jan 19
2
Easy way to handle form input without a model class?
I have a couple forms that I''d like to be able to validate and
automatically populate, but it shouldn''t be based on AR. In fact I
often have a bunch of small forms that I can''t really justify writing
a whole new model class for anyway. I''d like to validate the form
input, and then use rails helpers to automatically populate the form
if validations fail.
2006 Jun 03
1
Can I tell if the associated record is new in a belongs_to save?
In a belongs_to association, is there a way to tell if the associated object
was newly created?
Hopefully this will explain my question:
A Firm class declares
has_many<http://api.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.html#M000530>:clients
and a
client class declares
2006 Mar 18
1
has_many and validates_associated
By trial and error I seem to arrive to the conclusion that
1. Validation recurses through has_many by default and
a root save! call raises an excepcion if some child no
matter how nested is fails validation
2. Validation does not recurse through has_one by default
and you can change this with validates_associated, in
which case exceptions behave like above
2003 May 05
2
(PR#1289)
Dear all,
I've found a bug report for R when installing it on an AIX5.1 system.
There's a followup (number 4) that comments a segmentation fault on R
when quitting "q()".
I'm using a newer version of R but on the same operating system and
I obtain the same error.
There was a way to solve this problem?
Best regards and thanks,
--
2007 May 28
2
Rails, respond_to? over anonymous module (extend has_many).
Hello List,
I''m trying to generate examples for some list-helpers I have coded
which use in my projects.
Basically, the Playlist class uses one anonymous module in has_many
that acts as helper between acts_as_list and my desired API:
class Playlist < ActiveRecord::Base
# associations go here
has_many :playlist_items, :order => :position, :dependent => :destroy
has_many
2003 Oct 29
1
Environment set on PAM module is not visible to user
We're using an internal PAM module (Linux) that sets a few environment
variables using pam_putenv (on pam_sm_authenticate). In version 3.6.1p1i
such variables are visible to the user (as expected), but since 3.7p1
they are not...
Is this the expected behaviour?
Thanks in advance,
Jose
____________________________________________________________________________
Jose A. Rodriguez
2007 Aug 09
0
TypeError: $_ value need to be String (nil given)
Hello all,
I am trying to run a unit test in a Rails project of mine (Rails
1.2.2, Ruby 1.8.4 (2005-12-24) [i486-linux]), and am running into the
following error:
1) Error:
test_pattern_splits(PatternSplitTest):
TypeError: $_ value need to be String (nil given)
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/active_record/
validations.rb:74:in `split''
2006 Oct 13
3
Validation errors in has_one/belongs_to relationships.
I have two objects, QuoteInput and Insured.
QuoteInput has one Insured and Insured belongs to QuoteInput.
I don''t understand what I''m seeing.
I assign an Insured to a QuoteInput. The Insured object has invalid
data.
I call save! on the quote input. QuoteInput has no validations.
I expect two things to happen - 1) an exception should be thrown,
indicating that there was a
2011 Jun 15
1
.new_record? and :_destroy
Rails version 2.3.8
I have a ticket model that has many comments
the comments have an attribute called "admin" -- is this a comment
added by an administrator
the ticket has an attribute called "admin_email_address"
I want to validate when saving the ticket and say "if I have a new
admin comment, make sure I have an admin_email_address"
In my ticket model, the
2007 Jun 29
1
attachment_fu validation error
I have this class:
class Logo < ActiveRecord::Base
has_one :something
has_attachment :content_type => :image,
:storage => :db_file,
:max_size => 500.kilobytes
:thumbnails => {:web => ''150x100'', :pdf =>
''150x100''},
:processor =>
2008 Aug 31
9
assigning collection values and exceptions
hi everyone,
I''ve this code in my Report model:
has_many :report_reasons, :validate => true
has_many :reasons, :through => :report_reasons #, :uniq => true
# :accessible => true
def reason_attributes=(reason_attributes)
reasons.clear
reason_attributes.uniq.each do |reason|
reasons << Reason.find_or_create_by_content(reason)
end
end
2007 Nov 14
1
has_many_polymorphs and acts_as_list ?
First, BRAVO for this wonderful plugin: has_many_polymorphs ! Now my
problem:
4 models : Collection, Page, Fragment, Belonging (which is the join
table):
1 class Collection <
ActiveRecord::Base
2 has_many_polymorphs :elements,
3 :through => :belongings,
4 :from => [:pages, :fragments, :collections],
5 :as => :collector,
6 :parent_order =>
2009 Jul 01
1
form_for resources with :singular specified
I fully suspect that I''m missing the point here somewhere so I promise
I won''t be offended if you tell me I''m being daft.
My application rents equipment ... not equipments. So I have the
following:
map.resources :equipment, :singular => :equipment_instance
class Equipment < ActiveRecord::Base
class EquipmentController < ApplicationController
The
2011 Sep 05
3
function censReg in panel data setting
Hello all,
I have a problem estimating Random Effects model using censReg function.
small part of code:
UpC <- censReg(Power ~ Windspeed, left = -Inf, right =
2000,data=PData_In,method="BHHH",nGHQ = 4)
Error in maxNRCompute(fn = logLikAttr, fnOrig = fn, gradOrig = grad,
hessOrig = hess, :
NA in the initial gradient
...then I tried to set starting values myself and here is
2008 Jan 31
4
reby-debug and rspec
How do I use the ruby debugger with a specific test (not the whole spec file)? I want to do something like this.
$ rdebug spec/models/user_spec.rb -s "should error if not new_record"
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search.
2006 Feb 12
6
habtm doesn''t save old IDs
I''m sure I''m not getting something. I have Users, and I have Groups.
Each User has_and_belongs_to_many :groups and each Group
has_and_belongs_to_many :users.
When I add a user, I want to apply a bunch of groups (like tags) to the
user (manually, without acts_as_taggable).
Here''s User#create:
@user = User.new(params[:user])
@user.groups =