similar to: Using conditions in ActiveRecord

Displaying 20 results from an estimated 10000 matches similar to: "Using conditions in ActiveRecord"

2010 Nov 30
4
Cucumber+Capybara rails 3 issue (Don't know where exactly)
When I''m executing cucumber tests, I noticed that sometimes rails app (in test env.) getting several the same requests (GET or POST) usually around 3, and it doesn''t render anything with empty HTTP status code. Have anyone met something similar to that issue? here is some example of log file: Started POST "/account" for 127.0.0.1 at 2010-11-30 22:34:17 +0200
2006 Jan 31
4
has_one without inverse belongs_to
I have two models called entity and user. The entities table has a column called users_id that contains the user id of the user that created the entity. In entity I have... has_one :user ... as I want to be able to show the user who created the entity from the entity object. But this produces the following error... Mysql::Error: #42S22Unknown column ''users.entity_id'' in
2009 Feb 15
3
conditions on association include, hacky but more or less solved
Hi all, I just finally figured out how to get 2.2.2 to do this, and thought I''d share in case others run into the same thing. The situation is a find with associations, but the tricky part is that the association shouldn''t always be loaded. This is similar to putting a condition on a has_many association in a model, but the condition is dynamic rather than predefined. The
2007 Feb 12
2
Objects in Arrays? Allowed, right?
Hi: I''m trying to manually append objects to an instance variable that is just an array of objects. Here''s my controller code: @tasks = Task.find(:all, :conditions => "entity_id = #{session[:user].id}") for t in @tasks if Subtasks.find(:first, :conditions => "child_id = #{t.id}") != nil @mtasks << t end end However, when I execute, I
2005 Jun 30
2
Find by ID plus conditions -> ActiveRecord::RecordNotFound
Hi I''m trying to understand the AR find facilities, described here: http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000650 I have a list of ids that I want to retrieve, but have a condition that should restrict the list returned: return self.find( noteids, :conditions => [ "(private = 0 OR (private = 1 AND user_id = ?))", userid] ) According to the
2006 Nov 04
2
adding a method to an ActiveRecord Object
I''ve already pulled my object from the database. Now I want to add a method. What I''m doing is adding the username to the activerecord object so I''ll have the name and user_id. How can I do this. The code below fails in the view. It appears it''s overwriting the rest of my object def self.find_with_author(id) @article = Article.find(id)
2005 Aug 28
6
ActiveRecord Question
Hi all I am new to Rails, and obviously I''m missing something, I''ll get straight to the question: A User has many operations (granted to her), each Operation is associated with an OperationType. Each Operation may be associated with more then one User. So the model goes like this: class User < ActiveRecord::Base has_and_belongs_to_many :operations
2009 Dec 15
0
Problems reloading plugin extending AR model
Hi, I have an AR model called Entity, which is extended in a plugin like this (this is in a file under lib/ which is required by init.rb of the plugin): http://github.com/dedomenon/madb_notifications/blob/master/lib/madb_notifications_lib.rb#L8 Entity.class_eval do def user_subscribed_to_creation?(user_id) NotificationSubscription.find(:first, :conditions => [ "source_filter
2014 Jun 17
1
GPU lockup - switching to software fbcon
Hi. I am new to the listm so, first of all I'd like to say hello to everyone here in the list. I hope this list is an adequate place to post this; else, please, kindly direct me to the right list :) I write because I am having an issue with nouveau and mplayer. I have been only able to reproduce it with mplayer, but I think the issue lies in nouveau, either the kernel part or libdrm. The
2006 Feb 21
5
Abstracting ownership verification out of Controller
Right now I have a controller for "events" that belong to a specific user. I only want the creator to be able to edit or delete the event. I''ve got the proper foreign keys set up. I''ve finally arrived at the point where I can take baby steps with code, but looks like my first steps are in flagrant violation of the DRY principle. Here''s what I have so far in
2006 Apr 07
2
ActiveRecord find all based on array -- need ids from array
Does anyone know if it is possible to perform an ActiveRecord find by passing in an array? I would like to be able to do the following: MyModel.find(:all, :conditions => ["user_id in (?)", users]) The problem I run into is that the returned SQL contains the to_s() output of the User object, not the ids of those users. Is it possible to change this behavior? I attempted to
2017 Aug 25
2
retrieve machine password in current Samba?
We have a wireless network that uses 802.1x authentication, in which domain joined computers use their machine credentials to connect. Windows machines do this automatically, and until recently Linux computers could join using wicd, wpa-supplicant, and a simple script that would retrieve the machine password with tdbdump. ( specifically tdbdump -k SECRETS/MACHINE_PASSWORD/DOMAIN
2008 Feb 25
4
Using group in with find in an ActiveRecord appropriately
I''m playing around with the Practical Rails Projects code, and was attempting to make a change for graphing data differently using groupings. Basically the code went from: total_weight = @exercise.activities.collect {|e| e.repetitions * e.resistance} workout_dates = @exercise.activities.collect {|e| e.workout.date.to_s} To: total_weight =
2009 Dec 07
2
Xorg goes bonkers, bazillion NVIDIA errors...
on one of my Centos 5.4 boxes, a machine that's around 5 years old and has always run Centos and X, and has had the same Nvidia card in it for its entire life, I'm suddenly getting these lines in the xorg log file: (WW) NVIDIA(0): WAIT (2, 6, 0x8000, 0x00000000, 0x000003c0) (EE) NVIDIA(0): Failed to allocate clip rectangle (EE) NVIDIA(0): *** Aborting *** (EE) NVIDIA(0): Failed to
2019 Jan 21
3
Cannot start a secondary Xserver with resolution 6480x3840
Hi, In my workflow I am using several separate xservers. One for work, another for research and so on. Each of them has a separate user account, and they all belong to the same (main) group called janek. I've been using nvidia for years, but about 2 years ago some super annoying bug appeared in nvidia, namely that switching between virtual terminals sporadically causes nvidia_modeset to
2017 Dec 14
7
Question on CentoS 7.4 on nvidia
I installed the elrepo kmod-nvidia and also the nvidia-detect and modules (see below). I had X working with the 3.10 from Centos - but video was freezing. SO I thought I would try the elrepo kernel. I installed that and X does not come up? How do I re-make the nvidia module for 4.14.5 kernel? I want to make sure the kmod kernel did it. I 'm thinking it did not. lspci | grep VGA says
2006 Feb 28
6
Activerecord equivalent of the SQL "SUM()" function.
Search doesn''t seem to be working, so forgive me if I''m covering old ground here, but I''m having a difficult time figuring out how to implement a "SUM()" function using Active record. Obviously, I could just create a query, but I''d rather make it part of my active record object. Basically I have an object called "Report <
2018 Feb 01
2
Dovecot 2.3 on CentOS 7.
Greetings! I'm having a bit of trouble trying out Dovecot 2.3 on CentOS 7. Dovecot 2.2.33 works fine on the same system (same config as well, minus the SSL changes) but after upgrading to 2.3 I'm getting the following errors: Feb? 1 21:30:18 localhost dovecot: imap(reio at bwo.mrstuudio.ee)<3566><FoOsnStkXt4KAAgC>: Debug: INBOX.Templates: Mailbox opened because: STATUS
2017 Dec 15
1
Question on CentoS 7.4 on nvidia
Yan Li wrote: > If you need to use a non stock kernel, you can also try to download the > latest driver directly from nvidia. The nvidia official driver is very > easy to install and works with almost all kernel versions. It can also be > easily uninstalled too. Make sure you have the correct one, though. I have a number of systems with older NVidia cards, and have to pick and choose
2009 Aug 25
1
Filling in empty arrays/lists from using "paste" function
Dear R users, I am trying to fill in arrays (5 different according to distinct "id") from objects produced from arbitrary data set below. a <-