similar to: when to use find_by_sql

Displaying 20 results from an estimated 2000 matches similar to: "when to use find_by_sql"

2007 Jul 11
10
autocomplete in array
Experts, have you figure it out with autocomplete to pass as array objects? still i''m finding out the way to figure. :( regards, Bala --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2005 Dec 27
2
actions with no views?
In Depot, the demo application in the the Agile book, actions that modify the model such as add_to_cart redirect to another action that has a clear view role, like index, or show_cart, instead of generating the view themselves. This uses an HTTP redirect that goes to the client and returns. Is this an idiomatic way to design the flow in Rails? -- fxn
2008 Apr 30
6
best practice for object transaction?
I have a new @offer that needs to generate a document if saved. But that''s all or nothing: transaction do @offer.save! generate_document end # handle exceptions if needed If save! fails everything is fine, but if generate_document raises an exception @offer is left as a model with timestamps, id, which is not a new_record? anymore (though the database was
2005 Dec 23
2
SQLite in-memory
I left ":memory:" in database.yml for testing and the most simple tests in the Agile book do not work (see trace below for test_truth). Since that''s what comes with the distributed database.yml I suppose it''s me doing something wrong. Did someone get SQLite ":memory:" working? How does it grab the schema? -- fxn % rake test_units (in
2006 May 26
3
Breakdowns in has_many abstraction
I discovered an interesting aspect of has_many behavior that I''m struggling to work around. I''m not sure if I''m doing something wrong, or if it''s a legitimate bug, or if it''s an inherent part of Rails that I just have to learn to deal with. It boils down to these two problems: - changes in collection objects (i.e. models that belong_to a container
2007 Dec 10
2
Updating Rails to 2.0 on Mac OS X 10.5.1 won't work
Hi, I just wanted to update my Rails installation with "sudo gem update rails" but I get this error: Updating installed gems... Bulk updating Gem source index for: http://gems.rubyforge.org Attempting remote update of rails Install required dependency activesupport? [Yn] y Install required dependency activerecord? [Yn] y ERROR: While executing gem ... (OpenURI::HTTPError) 404
2005 Dec 25
3
SQLite primary key schema
So after successfully getting the test SQLite db to run from memory, I tried running some tests but found that somewhere in the schema translation from Postgres (my devel database) and SQLite Rails fails to properly set the ''id'' column, which breaks all kinds of things. Take as an example my ''users'' table. In Postgres the schema is (generated with pgAdmin III):
2009 Feb 27
4
Optimize for loop / find last record for each person
I want to find the last record for each person_id in a data frame (from a SQL database) ordered by date. Is there a better way than this for loop? for (i in 2:length(history[,1])) { if (history[i, "person_id"] == history[i - 1, "person_id"]) history[i, "order"] = history[i - 1, "order"] + 1 # same person else history[i,
2007 Oct 12
3
whats the right way to avoid this nil error..
I have an model Order and a model Customer. Each customer has_many Orders. Each Order belongs_to a Customer. If I create an order but don''t specify a Customer (for whatever reason, maybe it''s unknown at the time).. I obviously can''t access @order.customer.name because I''ll get a nil error... So what''s the right way to handle that? If the Customer is
2006 Mar 13
3
HABTM: two habtm''s between the same two tables
Imagine I want to track people, and the clubs that they belong to. table people with columns person_id, person_name table clubs with columns club_id, club_name And I have the association table: table clubs_people with columns person_id, club_id Now I know how to do this habtm between the two, in order to associate people with clubs that they belong to. However my application also needs a
2006 May 16
1
:conditions on has_one realationship
Hi there, I''m currently building a membership application and I want to be able to select, not just all the memberships, but the most current membership from the database on a per user basis. I have linked the tables as shown:- class Membership < ActiveRecord::Base belongs_to :payment belongs_to :person end class Person < ActiveRecord::Base has_many :memberships
2006 Jul 13
2
having a problem with acts_as_state_machine
Hi all: Below is s a dump from script/console in development env. Am I not supposed to be able to find the record later and use the state machine functionality, or have I missed something? Thanks Forrest ---------------------------- >> ts2 = TalkSession.create( :person_id => 2, :pattern_id => 2) => #<TalkSession:0x35811f0 @attributes={"pattern_id"=>2,
2006 Jan 09
3
Design Question
I am sure some of you can give me an insight into this. This is more towards the database design for the scenario below: Say for example, I have a person table and this person can have different address types. One could be Home and the other could be say Office. Should be model this Table people id fname lname Table addresses id person_id addr1 addr2 .... or Table people id fname lname
2008 May 02
1
names of select elements inside a fields_for block not generated as expected
Hey All, I''m trying to play along w/the ''complex forms 1'' railscast (http://railscasts.com/episodes/73) and having trouble. The view is projects/new. I''m trying to add some project_people to the form w/code like so: <% form_for(@project) do |f| %> [project stuff here] <% for pp in @project.project_person %> <% fields_for
2006 Jun 06
1
Please Help with single table inheritance relationships
I''ve been searching the web, wikis, and more, and I haven''t turned up examples of how to have multiple entities in a single-table inheritance related to anything. I have an addresses table, but multiple entities can have Addresses: both Person (which has 2 addresses) and Retailer. I''ve been told that I need to use single-table inheritance, and this was my attempt:
2008 Apr 30
7
rescue_from issue with AWS - uninitialized constant
The new rescue_from in edge rails seems to conflict with ActionWebService, which I need for various other purposes. When I define, for example (with AWS gem installed): <b>rescue_from ActionController::RoutingError, :with => :page_not_found</b> I get the exception: <b>uninitialized constant ActionWebService::Dispatcher::ActionController::Base</b> OK, so AWS
2007 Feb 26
4
update_attributes and validations
I have a Person model. Person has_many lab_urls. The LabUrl model has a title and a url, which are both required. Now, I want to update a LabUrl object and stick some invalid data in there. And I want the person that has that invalid LabUrl to now be invalid, too. That doesn''t seem like too much to ask for. How can I do that? Right now, this is happening: >> me = Person.find(1)
2006 Mar 09
4
sort-weirdness - active record issue?
I''m selecting data into a controller and sorting it. The code (in the controller) looks like this: def index @assignments = [] tasks = Task.find(:all, :conditions => ["person_id = ? and actual_end_date is null", session[:user].id.to_s ]) issues = Issue.find(:all, :conditions => ["person_id = ? and status <>
2010 Nov 02
7
Testing attr_accessible (and/or attr_protected)
I''ve been puzzling over how to test that attr_accessible has been set for the correct columns; but the tests I''ve come up with so far seem to fail to fail when I expect. I came across this old message from this list: http://www.mail-archive.com/rspec-users at rubyforge.org/msg01570.html Which seemed like a plausible example, but my attempt (modeled on the example)
2013 Nov 19
1
Does function read.sas7bdat() have some memory limitations?
Dear R-ers, I was trying to read in a large sas7bdat file (size 148094976 bytes) using 'read.sas7bdat()', but it did not read in the data correctly. E.g., the first 5 rows will come out like this (I'm omitting other columns to keep it readable): PERSON_ID age 1 5.399114e-315 5.329436e-315 2 5.399114e-315 5.328302e-315 3 5.399114e-315 5.332026e-315 4