similar to: validation on before_add callback

Displaying 20 results from an estimated 1000 matches similar to: "validation on before_add callback"

2010 Jul 12
1
How to turn :before_add exceptions into validation errors
As per http://rails.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html Possible callbacks are: before_add, after_add, before_remove and after_remove. Should any of the before_add callbacks throw an exception, the object does not get added to the collection. Same with the before_remove callbacks; if an exception is thrown the object doesn‘t get removed. However, when the add
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 May 10
8
dynamic setting of username and password in database.yml
Hello I''ve now read a lot about application-level authentication in Rails, but I need to do database-level authentication. The reason is that my database needs to have the current_user (database current_user, not current_user defined in an ActiveRecord Model) set to execute triggers for automatically updating audit tables. So it is not enough to have a session check against a User
2007 Jun 18
4
polymorphic validation
Hello I have 2 models. link.rb has_many :categories, :as => :categorized validates_presence_of :name, :url, :created_at, :category category.rb belongs_to :categorized, :polymorphic => true validates_presence_of :name Everything seems to work. I select my category from a select tag. The problem is i don''t know how to validate if category is for example empty (nothing in a
2006 Jun 01
4
how can I control when to commit a transaction?
hello it seems like this question has appeared a few times with no answer: how do you get rails to issue ''write'' statements (ie ''CREATE/UPDATE'') to the database without committing each time? I tried setting ActiveRecord::Base.connection.begin_db_transaction before calling any action on my object, but as soon as myObject.save or myObject.update is called,
2000 Oct 26
2
Problem with lm
Hello Everybody, I have a problem with the output of lm. In fact, when I compare the R output and the Splus output, the results appears to be different : I have a dataframe with 5 factors , 16 rows and a response. First, I tried to fit this response to a linear model : lm(rep~(A+B+C+D+E),data). The results beetween SPlus and R are different. In a second time, I tried a new fit :
2006 Jun 01
4
Ruby on Rails strange issue
Hello, I just installed Ruby on Rails and created the new repository. I wanted to use Ruby on Rails with FCGI The repository was created in /path/to/public_html ls /path/to/public_html/ : app cgi-bin config doc log public README script tmp asd components db lib logo.jpg Rakefile README_LOGIN test vendor I installed fcgi support for ruby on rails and
2006 Nov 29
4
how do I model self-referential entities?
Hi all - I am having some trouble figuring out how to model self-referential entities in Rails. I have a "group" model, which can have 0 or more "group" objects or 0 or more "user" objects. I tried creating a subgroup table that has a parent_group_id and a child_group_id as foreign keys but can''t figure out how to create the mapping in my ruby model
2003 Sep 24
3
Problem with memory for large datasets
Hello, I would like to know if there is a possibility to "clean" the R memory during a R session. In fact, I realize a lot of instruction with large objects (matrix of 500*5000), and I can not manage to achieve the end of my script due to memory lack. Of course, I've tried to remove all "temporary object" during the script execution and to perform a garbage collector ...
2006 Apr 07
6
validation nightmare
Please help, I am really at a loss at how validation is supposed to work in rails. Model contains acts_as_tree I want to force my NEW objects to have a parent I do NOT want existing object to have a parent so I only want to have parent_id on create, NOT on update. I am trying this: def validate_on_create validates_presence_of :parent_id, :message => "You must specify a
2003 Apr 08
3
density ranges for uniform law
Hello, I would have some details and explanations about the results I get. In fact, I start with a uniform sample between -1 and 1, and then plot its density. My problem is that the density ranges are much more longer than I expected : samp <- runif(10000,-1,1) plot(density(samp)) Instead of varying between -1 and 1, the density varies between approximaly -1.5 and 1.5 Could someone explain
2001 Nov 08
3
Problem with optim (method L-BFGS-B)
Hello, I've just a little problem using the function optim. Here is the function I want to optimize : test_function(x){(exp(-0.06751 + 0.25473*((x[1]-350)/150) + 0.04455*((x[2]-40)/20) + 0.09399*((x[3]-400)/100) - 0.17238*((x[4]-250)/50)- 0.45984*((x[5]-550)/150)-0.39508*((x[1]-350)/150)* ((x[1]-350)/150) - 0.05116*((x[2]-40)/20)* ((x[2]-40)/20) - 0.27735*((x[3]-400)/100)*((x[3]-400)/100) -
2008 Apr 17
1
Moving from Splus to R: irregular and regular time series
Dear R developpers, I am a user of Splus since many years and I have developped lots of functions to plot graph of data and model results of irregular or regular times series. In Splus regular times series are created using the rts function and irregular time series using the its functions. In both cases, times is given as a numeric vector. There is no problem in plotting a regular and an
2001 Aug 21
2
Problem using GLM in a loop
Hello, I am try to perform a modeling which is relevant in a strongly heteroscedastic context. So I perform a dual modeling (modeling of both mean and variance of a response) in using the following loop: jointmod <- function(formula, data, itercrit=10,devcrit=0.0001) { # # Init step # init <- glm(formula=formula,family=gaussian, data=data) response <-
2000 Oct 16
2
Crash while R111 install
Hello, I try to install the R111 version for few days on my PC (on Windows NT), and every time the same problem : I start the rwin.exe application and a couple of seconds later, the install failed, and my PC is down. I must then swich it down and restart a new session. If someone has some help ... Thanks -- Isabelle Zabalza-Mezghani Tel : 01 47 52 61 99 Institut Fran?ais du P?trole
2003 Feb 17
2
Call to glm inside a function
Hello, I want to call glm inside a function. In the first lines of code I build the weights, the formula, ... and then I call glm with the following command: glm(formularesp, data=data, family=familyresp, weights=eval(data$weights) My problem is that the fitting proccess is performed just like if weights=NULL, even if my weights are not equals to 1. I've performed some return() command
2003 Jun 27
1
A vector or matrix response
Hello, I wonder if anybody has some idea about how to solve my problem : I am working , I would say trough an experimental design approach (perform experiments, get responses, make regression, sensitivity analysis, risk analysis ...). The problem is now that I have to face with not only a response but a vector or a matrix (typically a spatial distribution of a physical property ... pressure).
2003 Oct 27
1
Starting and Terminating the JVM for package SJava
Hello, I would like to know if there is a possibility to open an R session via Java (using the SJava package), then to terminate it, and re-run another. It seems not to be possible. If this is the case, I would like to understand where is the problem or the limitation (is it due to the SJava implementation, to the Java behavior, or to the R application). In fact, I am interesting in re-starting
2002 Nov 07
2
Qualitative factors
Hi, I have some doubt about how qualitative factors are coded in R. For instance, I consider a response y, a quantitative factor x and a qualitative factor m at 3 levels, generated as follow : y_c(6,4,2.3,5,3.5,4,1.,8.5,4.3,5.6,2.3,4.1,2.5,8.4,7.4) x_c(3,1,3,1,2,1,4,5,1,3,4,2,5,4,3) m_gl(3,5) lm(y~x+m) Coefficients: (Intercept) x m2 m3 3.96364 0.09818
2006 May 03
2
render partial collection
my view contains a call to a partial: <%= render(:partial => ''item_list'', :collection => @keyword.synonyms, :locals => { :action_delete => "removesynonym", and_some_other_stuff }) %> _item_list.rhtml contains: <%= link_to ( image_tag(''/images/deletebutton.png''), { :action => action_delete, :id =>