similar to: Check if row already exists?

Displaying 20 results from an estimated 20000 matches similar to: "Check if row already exists?"

2006 Jun 08
5
Displaying Calculation on Index
Hi, I am trying to create a simple point system and display the total on my index page. So I have my db basically setup like this: Posts id, body, created_at, user_id Post_points id, post_id, user_id, created_at, value So as you can see I am allowing other users to create points on the post and my db will store who gave the point as well. "value" is the point value which can
2004 Feb 19
1
reshape direction=wide
Hello I am reshaping a data.frame bids --> reshaped as shown below. I thought this should be possible with a single invocation of reshape, but the only way I came up with is reshaping subsets for each keyword and then joining them together. Does anyone have an idea how to solve this in a more elegant way? Efficiency is a concern as the datasets are very large. Is there a way to specify
2006 Jul 06
2
@oldbid = 0 why?
Okay I''ve been working on a little biding system. In my model I have class Item < ActiveRecord::Base has_many :bids def highest_bid @bid = 0 self.bids.each do |bid| if @bid == nil @bid = bid.max else if bid.max > @bid @oldbid,@bid = @bid,bid.max end end end if @oldbid == 0 "#{@bid} - #{@oldbid+1} = #{@bid -= @oldbid+1}" else dif =
2010 Oct 04
3
Loop too slow for Bid calc - BUT cannot figure out how to do with matrix
Hi, I am trying to create Bid/Ask for each second from a high volume stock and the only way I have been able to solve this is using loops to create the target matrix from the source tick data matrix. Looping is too slow and not practical to use on multiple stocks. For example: Bids Matrix (a real one is 400,000++ length): Bid Time 10.03 11:05:03.124 10.04 11:05:03.348 10.05
2009 Dec 03
2
Dynamic Paths
Hey there, I''m in the muck of a major rails project, and need a bit of advice. Google isn''t much help in this case, so I came here. I''m trying to set up a URL structure as follows: url.com/username/blog/post_id where the user has_many posts and the post belongs_to user. I''m using the friendly_id plugin to enable easy lookup with the user''s username,
2011 Apr 19
1
RSpec/Webrat Checking output is properly escaped
I want to test that the JSON response from a create action is sanitized properly, but rspec or webrat appears to be parsing the output into proper HTML chars instead of escaped characters. I have verified that it escapes properly in the regular browser json response. The relevant RSpec test code is: include ActionView::Helpers::TextHelper include ActionView::Helpers::UrlHelper it
2006 Jul 02
2
nil.- what the heck...
Okay first off here''s the error: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.- Here''s the code in the model: def highest_bid @bid = nil @oldbid = 0 self.bids.each do |bid| if @bid == nil @bid = bid.max else if bid.max > @bid @oldbid,@bid =
2006 Mar 16
0
Conflicting Attributes in Model and Join Table...
Hi all, I''ve got a Post and User classes. The Post has a user_id attribute to point to the user that created it. I want to implement favorites, so I made Post and User both "has_and_belongs_to_many" and created a favorites join table. The join table has a post_id and a user_id column. Now when I get my post everything seems to be okay, but in some contexts, the user_id
2006 May 05
1
Help with ActiveRecord
Model: class AdminQueue < ActiveRecord::Base set_table_name ''adminqueue'' end Interacting with it in script/console >> AdminQueue.new => #<AdminQueue:0x240a910 @attributes={"topic_id"=>nil, "resolved"=>nil, "updated_on"=>nil, "action"=>nil, "type"=>nil, "post_id"=>nil,
2006 Jun 18
3
Ambiguous clause error
I''m trying to query one table to ultimately display the relate info from another table. I have 2 tables: "posts" and "numbers". I''m trying to do a query like this: @numbers = Number.find(:all, :conditions => [ ''(user_id) = :id'', {:id =>
2011 Nov 23
0
Awesome nested set - how to put there items?
hello guys, I have following structure of the table, where I store items of tree: | id | int(11) | NO | PRI | NULL | auto_increment | | user_id | int(11) | YES | | NULL | | | parent_id | int(11) | YES | | NULL | | | lft | int(11) | YES | | NULL | | | rgt | int(11) | YES
2008 Apr 14
2
Problems with nil object
Hi to all. I''ve a very big problem. I know this can seem very loing, but please, try to read it. I have a simply blog, with posts and their comments. I''ve two tables in my db, posts, with post id, text and comments_count to store the number of comments-children of each post (as recomanded to do in AWDWR); and the table comments, with comment id, post_id for the post
2006 Jan 23
2
del.icio.us-like output
I''m trying to build a page similar to a delicious page that is a listing of your bookmarks in this format: 1. Querying serialized data in ActiveRecord<http://www.karmiccoding.com/articles/2005/11/29/querying-serialized-data-in-activerecord> Hack to search serialized fields to rails <http://del.icio.us/djsodom/rails> ... and 4 other
2013 Jul 15
3
[Bug 2128] New: ssh-copy-id doesn't check if a public key already exists in a remote servers ~/.ssh/authorized_keys file
https://bugzilla.mindrot.org/show_bug.cgi?id=2128 Bug ID: 2128 Summary: ssh-copy-id doesn't check if a public key already exists in a remote servers ~/.ssh/authorized_keys file Product: Portable OpenSSH Version: -current Hardware: Other OS: Other Status: NEW Severity: enhancement
2006 Jun 08
3
Foreign key confusion
I have 2 models right now: "users" and "posts". When a user creates a post I would like their id to be recorded under "user_id" in the "posts" table. Under the "user" model I have: class User < ActiveRecord::Base has_many :posts end And under the "posts" model I have: class Post < ActiveRecord::Base belongs_to :user
2006 Mar 02
0
syntax for number_with_precision
I normally use number_with_precision in my views and I''ve never had a problem. Now however, I need to use it in my controller because my Ajax method is calling the controller and the controller will return values to it which will be displayed in the span of my html document. In short, what am I doing wrong in the statement below? I need the ''bid'' to be formatted
2006 Apr 20
1
Returning Count from find_by_sql
I want to return an int from a find_by_sql call. But when I use that result to compare to another count the error tells me I have an array. MODEL: # Returns the number of comments in a specified post def self.find_count(post_id) find_by_sql(["SELECT COUNT(*) FROM commments WHERE post_id = ?", post_id]) end CONTROLLER: def test @post =
2006 Oct 28
1
really strange problem - has to be logic but i can't find it
would someone be kind enough to paste the code below into an R session ( ir you can paste it into a file and just source it ) and take a look at it ? I must be doing something wrong but i can't find it. I start out with a zoo object that has 100 elements in it. then, i only want to keep the rows in which the bid and the ask are both grester than zero. ( maybe my logic is wrong there ? ).
2007 Jan 01
0
Simple question on inserting child data
after doing a bunch of reading I have finally sat down to create a simple app to dirve home a lor of the concepts to which have been read. So I figured a simple blog app is the best way to do it. The bad thing is that I am already hung up when creating replies to a blog posting. I can''t figure out how to insert the post_id value into the reply table. When creating a reply the user is
2006 Jul 12
1
odd habtm behavior? or is it me?
Hello List, I''m a bit spent on this problem, and my code might be whack. I seem to be encountering a problem where the primary key on a join table is not being resolved correctly. I will elaborate after some code bits. I am creating the join table using migrations, and relevant model code is this: class Post < ActiveRecord::Base has_and_belongs_to_many :records