similar to: Model names in controllers

Displaying 20 results from an estimated 1000 matches similar to: "Model names in controllers"

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
2012 Mar 22
1
why doesn't .where() honor polymorphism?
I love the query interface (ActiveMethod::QueryMethods), 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
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 --
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 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 ...
2012 Oct 01
1
active_model_serializers, more than one level deep of associations, specifying serializers per association
I am assuming this an appropriate place to discuss this, but if it isn''t my apologies- just let me know. Just a Rails 4-ish thing. Am attempting to pull AMS (active_model_serializers), strong_parameters, and the "permitter" strategy that Adam Hawkins is using: http://broadcastingadam.com/2012/07/parameter_authorization_in_rails_apis/ Code so far is here (in the
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",
2011 Apr 10
0
Arel Union does not support #order or #limit
I just posted this ticket in Lighthouse, but thought perhaps some discussion here would help point me in the right direction toward a solution. Here is a description of the problem (from the ticket - https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6693-arel-union-does-not-support-order-or-limit) : > If we take two `ActiveRecord::Relations` and join them via `union`:
2008 Feb 13
4
Migration Issues: Can't update newly added column values
Hello everyone, just wondering if anyone can help me with a migrations question here. Using: rails 2.0.2 ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin] mysql 5.0.45 Platform: windows xp The problem: ---------- I created a migration that is designed to add a column named "deleted_at" (timestamp) and then remove a column named "is_deleted" (boolean). The idea is to
2013 Feb 03
4
Create a helper for models and views?
Hi! If I have a method that is useful in both models and in views, where would be the appropriate place to put it? The method in question just takes two dates as strings, tries to parse them and returns all dates in the range between them. It also takes care of the issues when the dates are badly formatted etc etc.. This method is being used in several models (so a simple class method in
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:
2006 Apr 14
5
state_models plugin and file_column?
I was looking at Kyle Mawell''s extremely nifty-looking StateModels plugin http://www.kylemaxwell.com/articles/2006/02/06/fun-with-single-table-inheritance and before I go down the road with it, I was wondering if anyone has used it with file_column. The way file_column deals with an uploaded file -- by storing it to the filesystem in a path that employs the model name and id --
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]]
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
2017 Jun 26
3
Jagged ROC curves?
Hi, I was trying to draw some ROC curves (prediction of case/control status), but seem to be getting a somewhat jagged plot. Can I do something that would 'smooth' it somewhat? Most roc curves seem to have many incremental changes (in x and y directions), but my plot only has 4 or 5 steps even though there are 22 data points. Should I be doing something differently? How can I provide a
2010 Jan 01
1
Questions bout SVM
Hi everyone, Can someone please help me in these questions?: 1)if I use crossvalidation with svm, do I have to use this equation to calculate RMSE?: mymodel <- svm(myformula,data=mydata,cross=10) sqrt(mean(mymodel$MSE)) But if I don’t use crossvalidation, I have to use the following to calculate RMSE: mymodel <- svm(myformula,data=mydata) mytest
2018 May 18
3
Exporting to text files
I have dose response data analyzed with the package 'drc'. 'summary(mymodel)' prints my kinetic parameters. I want that text in an ASCII text file. I want to get exactly what I would get if I copied and pasted from the terminal window. I've read the documentation on data export to text files here:
2008 Apr 17
1
How to extract vectors from an arima() object and into a data frame?
This should be very easy, but alas, I'm very new to R. My end goal is to calculate p-values from arima(). Let's say I just ran this: > MyModel <- arima(y[1:58], order=c(1,0,0), xreg=MyData[1:58,7:14], > method="ML") > MyModel And I see: arima(x = y[1:58], order = c(1, 0, 0), xreg = MyData[1:58, 7:14], method = "ML") Coefficients: ar1
2006 Nov 16
2
dynamically adding static (class) methods to a class
Hello again, I guess this is more of a Ruby question, but here goes anyways... I want to intercept all calls to non existent class methods and then call an existing class method with the non existent name. In code... class MyModel < ActiveRecord::Base def MyModel.method_missing(symbol, *args) MyModel.func(symbol.id2name) end def MyModel.func(func_called) puts "You
2018 May 18
0
Exporting to text files
?sink On May 18, 2018 9:47:25 AM PDT, Ed Siefker <ebs15242 at gmail.com> wrote: >I have dose response data analyzed with the package 'drc'. >'summary(mymodel)' prints my kinetic parameters. I want >that text in an ASCII text file. I want to get exactly what I >would get if I copied and pasted from the terminal window. > >I've read the documentation on