Displaying 20 results from an estimated 47 matches for "my_model".
2006 May 19
1
FileColumn
I''m using Windows and Postgres 8.
I installed RMagic gem thingy and FileColumn plugin ok.
I followed instructions exactly as directed on FileColumn web site which
is very straight forward:
---model
class My_model < ActiveRecord::Base
file_column :column_for_file_name
end
-----view -upload form--set to mulitpart
<%= file_column_field "my_model", "column_for_file_name" %>
---controller
upload
@my_model = My_model.new()
@my_model.save(params[:my_model])
end
I get...
2011 Apr 10
0
Arel Union does not support #order or #limit
...el_a = ActiveRecord::Relation.new(MyModel).where(:id => 3)
> rel_b = ActiveRecord::Relation.new(MyModel).where(:id => 5)
> new_rel = rel_a.union(rel_b)
> new_rel.to_s #=> "#<Arel::Nodes::Union:0x3da6260>"
> new_rel.to_sql #=> "( SELECT `my_models`.* FROM `my_models`
> WHERE (`my_models`.`id` = 3) UNION SELECT `my_models`.* FROM
> `my_models` WHERE (`top_items`.`id` = 5) )"
>
> Ideally, we''d be able to sort and limit the resulting `UNION`
> results in the SQL. According to [the MySQL docs for the UNION
&...
2005 Apr 24
2
Model names in controllers
...c:/program files/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/dependencies.rb:75:in `require_dependencies'': Missing model MyModel.rb
From these lines of code:
class MyModelController < ApplicationController
model :MyModel
end
The model''s file name is my_model.rb. If I rename the file to MyModel.rb
it works, or if I change the line of code to model :my_model it works. I
used the generator for the model so it seems that the file name should
follow rails conventions. But it seems that the model method of
ApplicationController is looking for a file name...
2005 Apr 10
2
residuals in VGAM
Hi all:
I want to fit a multinomial logit model with VGAM package, however I cannot find a way to check the residuals since
residuals(my_model) and resid(my_model)
does not work.
Any suggestions?
Thanks in advance.
Alex Brito
[[alternative HTML version deleted]]
2007 May 21
7
How do I stop a column being updated by model.save?
One of my models has a column that is updated very frequently from a
separate process, so it is important that when a record is saved in
rails, this column should be left alone. In the update method of the
controller I have:
@record = MyModel.find(params[:id])
@record.update_attributes(params[:my_model])
params[:my_model] doesn''t have a reference to the column I''m talking
about, however, the UPDATE statement produced by update_attributes will
still assign a value to this column.
Even though its unlikely, if the separate process updates the record in
the time betweent the find,...
2017 Jun 26
3
Jagged ROC curves?
...ething differently?
How can I provide a URL/attachment for my plot? Not sure if I can provide
reproducible code, but here is some pseudocode, let me know if you'd like
more details:
#####
## generate roc and auc values
#####
library(pROC)
library(AUCRF)
getROC <- function(d1train,d1test){
my_model <- AUCRF(formula= status ~ ., data=d1train,
ranking='MDA',ntree=1000,pdel=0.05)
my_opt_model <- my_model$RFopt
my_probs <- predict(my_opt_model, d1test, type = 'prob')
my_roc <- roc(d1test[,resp_col] ~ my_probs[,2])
aucval <- round(as.numeric(my_roc$auc),4)
r...
2006 Jul 29
1
Anything wrong with this test? Cannot access fixture
Hi,
I have problem accessing the testfixture. The values from the
YML-Fixture-File are correctly written into database, but accessing the
fixture is impossible. It is always nil.
Is anything wrong with this test?
class MyModelTest < Test::Unit::TestCase
fixtures :my_model
def test_simple
a = MyModel.find(@my_model["first"].id) # Accessing @my_model is
impossible
...
end
end
Thanks,
Steffen
--
Posted via http://www.ruby-forum.com/.
2011 Aug 29
32
Weird assignment problem, very confused :(
Hey, I have the following line in my controller:
User.create(:email => "fuuu-+RB1Aph5k6s@public.gmane.org", :password =>
''asldfkjadsfadsf'', :ip => request.remote_ip)
my IP is 127.0.0.1 - now User.find_by_ip(''127.0.0.1'') returns 0
records although User.first contains ''127.0.0.1''
if I change it to:
User.create(:email =>
2006 May 08
7
How to get difference between two dates in days???
Hi,
I want to calculate difference between Current date & previous date
(stored in database). The difference should be in days. Hhow to do
that??
PLs tell me.
Thanx in advance.
Prash
--
Posted via http://www.ruby-forum.com/.
2006 Sep 22
2
Editing the migration template
Hi. I''d like to edit the generated template in AR where tables are
created.
for example, this file is created when generating a new model or
migration:
class CreateModel < ActiveRecord::Migration
def self.up
create_table :models do |t|
# t.column :type,
I''d like to edit the above so it''ll generate this:
class CreateModel <
2012 Oct 01
1
active_model_serializers, more than one level deep of associations, specifying serializers per association
...erated serializer and permitter classes for each model that has a
table (~270 permitters, ~270 serializers), which means a lot of attribute
and association name duplication, but it''s what I''ve got for now.
Running into some circular reference issues:
Started GET "/service/my_models" for 127.0.0.1 at 2012-10-01 16:56:29 -0400
Processing by MyModule::MyModelsController#index as JSON
MyModel Load (3.5ms) SELECT "my_models".* FROM "my_models"
MyModel2 Load (2.0ms) ...
MyModel3 Load (0.9ms) ...
MyModel4 Load (0.7ms) ...
MyModel5 Load (7.0ms)...
2017 Jun 26
0
Jagged ROC curves?
...for my plot? Not sure if I can provide
> reproducible code, but here is some pseudocode, let me know if you'd like
> more details:
>
> #####
> ## generate roc and auc values
> #####
> library(pROC)
> library(AUCRF)
>
> getROC <- function(d1train,d1test){
> my_model <- AUCRF(formula= status ~ ., data=d1train,
> ranking='MDA',ntree=1000,pdel=0.05)
> my_opt_model <- my_model$RFopt
>
> my_probs <- predict(my_opt_model, d1test, type = 'prob')
> my_roc <- roc(d1test[,resp_col] ~ my_probs[,2])
> aucval <- round(a...
2006 Jul 31
3
Missing controller default code
Hello,
I generated a controller, using the command:
ruby script/generate controller my_kontroller my_model
The generated controller file, however, contains an empty class
definition. The default controller code is missing.
Any idea what went wrong?
Thanks,
gk
--
Posted via http://www.ruby-forum.com/.
2012 Mar 22
1
why doesn't .where() honor polymorphism?
...), but one thing
has bugged me: why doesn''t it generate calls for polymorphic
associations? For example:
class MyModel < ActiveRecord::Base
belongs_to :parent, :polymorphic => true
end
I would expect:
MyModel.where(:parent => a)
to be equivalent to:
MyModel.where("my_models.parent_id = ? AND my_models.parent_type = ?",
a.id, a.class.base_class.name)
Is there a philosophical reason it doesn''t make this transformation?
- ff
P.S.: After writing this, I realize it''s not just for polymorphism. I
would expect the NON-po...
2006 May 31
1
ActiveRecord: When / where to validate data? Tricky question
First of all, thanks for you time. I have kind of a tricky question and
wanted to see what you guys thought.
-------------------------------------------
Lets say I have this:
-------------------------------------------
class Purchase < ActiveRecord::Base
validates_numericality_of :some_number, :only_integer => true
end
-------------------------------------------
Then I do this:
2010 Nov 03
2
[klaR package] [NaiveBayes] warning message numerical 0 probability
Hi,
I run R 2.10.1 under ubuntu 10.04 LTS (Lucid Lynx) and klaR version 0.6-4.
I compute a model over a 2 classes dataset (composed of 700 examples).
To that aim, I use the function NaiveBayes provided in the package
klaR.
When I then use the prediction function : predict(my_model, new_data).
I get the following warning :
"In FUN(1:747[[747L]], ...) : Numerical 0 probability with observation 458"
As I did not find any documentation or any discussion concerning this
warning message, I looked in the klaR source code and found the
following line in predict.NaiveBaye...
2006 Jul 20
7
How do you use :message with validation?
If I do validates_uniqueness_of :name, :message => "It''s not
uniqueeee!!!"
then how do I have it display that message when the check fails?
-Ben Lisbakken
--
Posted via http://www.ruby-forum.com/.
2006 Aug 09
1
How to Disable Callbacks on a Model
Does anyone know how to disable a model''s callbacks?
I have a routine that increments a page_view counter for various model
objects in an after_filter in my ApplicationController. I call this:
increment_page_view()
Rather that checking through the trace array in each model callback for
"increment_page_view" I''d rather disable the callbacks from inside
2006 Jul 14
3
override to_string for single attribute?
...e display for a single attribute
such that if the value is an integer, it displays with no decimal point
(e.g. "1"), but if it is non-integer, it displays with a decimal point
(e.g. "1.25").
The easiest way to do this seems to be if I could override the to_string
method for my_model.my_attribute.to_s. Is there a way to do this? Or
a better way altogether?
thanks,
Jeff
--
Posted via http://www.ruby-forum.com/.
2008 Mar 05
2
Testing that a model helper method is called
So, I have a plugin that adds a method to ActiveRecord::Base, let''s call the
method is_encrypted.
class MyModel < ActiveRecord::Base
is_encrypted
end
So, my question is, how do I write a spec to show that is_encrypted is
called here? I would rather not write specs that say that the behavior is
there, since I have tested the behavior already in my plugin.
Thanks.
-Corey
--