Displaying 20 results from an estimated 5000 matches similar to: "Foreign key confusion"
2006 Jun 07
1
Calling find on AR class, order by association count?
I suspect that this is going to wind up trivial and I''m going to slap
myself in the head...
Suppose I have User and Comment AR classes.
User has_many :comments, Comment belongs_to :user
I want to do a User.find, which returns User objects in order of which
user has the most comments. I suspect that this involves renaming the
COUNT(*) results of a sub-select so that I can order by
2006 May 31
3
Camping and Builder and XML
Hi,
I have built a simple Camping application which indexes an ODBC
datasource using Ferret on startup, then accepts search strings and
renders the resulting hit list in HTML, and it works quite nicely.
The next step was to alternately render the list in XML for consumption
by another application. In Rails, I would simply use Builder in the view
to get the job done, and so I did the same in
2006 Jun 08
2
Does Edge Rails play well with GEM Rails?
Hi,
I have the current version of GEM rails installed on my machine at the
moment. I would like to put edge rails on for a project that I''m working
on, but I would like to keep the Gem version, at least for the moment.
Also is there any documentation about installing Edge rails? I have looked
on the wiki but it was not obvious to me where it is.
Cheers
Daniel
-------------- next part
2006 Jun 11
3
[SUMMARY] Rails Core Weekly June 5 - June 11
Dear list,
This weeks RCW has a slightly different format than before. After all,
since what we want is less bloat, this RCW is less verbose. Please do
let me know what you think off-list.
*Interesting stuff on the Rails Timeline*
_Fixed and commited to trunk:_
An issue with not null columns in SQLite3 migrations(<a
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 =>
2006 Jun 07
4
Edge rails and routes
I have a route that works under 1.1.2 but does not work under edge
rails.
route.wishlist ''wishlist/:id'',
:action => ''show_wishlist'',
:id => nil,
:requirements => {:id => /\d*/}
This worked great without an :id, but under edge rails when I call
wishlist_url with no parameters I get:
"Exception: can''t convert nil into
2006 Jun 16
4
Unit test and get request with a URL
I''m tyring to write a unit test that uses a get() method to simulate a
get request in my functional test. However, get wants an action, and I
have a URL. I''m trying to redirect to a URL the user tried to hit
before logging in. After they login I want to go back to the URL they
originally tried.
I can''t find the get() method code in the help or otherwise. I
2006 Jun 07
10
habtm "AND" find conditions
I have two tables and a join table for them
e.g. books, authors in a many to many relationship (habtm) and a join
table books_authors.
I can successfully search for a book that has
"author.id = 2 OR author.id = 4"
but I am unable to search for
"author.id = 2 AND author.id = 4"
This is because the result of all the joins only has one author.id
column so no single row has
2006 Jun 18
1
Query
If there were a project to integrate Hobix with Camping, should it be
called ShantyTown?
Thanks,
-mental
2006 Jun 16
1
Is there a way of retrieving all req parameters without name
Is there a way of retrieving all the request parameters without name in
the controller.
Thanks & Regards,
Asem
--
Posted via http://www.ruby-forum.com/.
2006 Jun 07
1
has_many, through, want to store email in mysql
Hi,
I''m still a new with ROR, but it''s really cool :) I just have this
problem with a project of mine.
I want to store email in a database. I already wrote a simple import
script, that works, so that''s not a problem. Showing the email
(efficiently) in a ROR site is.
These tables are in the database:
emails
id
email_id (foreign key -> emails.id)
seq
2006 Nov 14
11
RESTful mixin, mixin repo?
Hi,
I just put together a little mixin to provide pseudo-RESTful services
in camping apps. Basically, it looks for a hidden _verb field in form
posts, and sets the @method to the supplied value (e.g. put or delete
- which browsers don''t support). This lets you define put and delete
methods in your controllers. Groovy.
Code:
http://pastie.caboo.se/22613
Is there any permanent repo of
2006 Jun 10
3
Inserting data to another DB table
I have a form under one controller/model called "billing" using the
"bills" table. When this form completes I want it to change the
"has_billing" field for the user under the "users" table from "0" to
"1". I''ve almost got it. I put:
user = User.new
user.update_attribute("has_billing", "1")
under the
2006 Jun 16
7
How to pass params to long running system call
Hello,
Can someone tell me the best way to make a system call (from within my
model) that runs for a while and requires params form my model,
specifically attributes of my model.
So, I need the correct syntax and also general guidelines for launching
the process.
Thanks so much.
Regards,
Doug
--
Posted via http://www.ruby-forum.com/.
2006 Jun 13
9
Find DB items by "title"
I''m having trouble finding then displaying all items in my "posts" table
that match a certain search string.
I have a from field:
<%= start_form_tag :action=> "search" %>
<div title="Search" id="searchform" class="form">
<h3>Search</h3>
<%= error_messages_for ''post''
2006 Jan 13
4
missing foreign key fields in scaffold views
Is there any reason that foreign key fields do not show in any of the
scaffold views ?
project table:
id serial primary key,
category_id integer,
user_id integer,
name varchar,
morestuff varchar
foreign key (category_id) references categories(id),
foreign key (user_id) references users(id)
scaffold generated views only show name, morestuff fields
2008 Apr 18
3
has_many and belongs_to with non-primary foreign keys
Hi,
I''m having a bit of trouble with my first Rails app.
----
I have two tables:
create_table :items do |t|
t.column :created_at, :timestamp
t.column :user_id, :int
t.column :text, :text
end
create_table :users do |t|
t.column :user_id, :int
t.column :name, :string
end
----
I''m trying to use the "user_id" field to link both tables, with each
user
2006 Mar 06
2
Confusion about construction of RURIs from contact headers for BYEs generated by *
I'm a bit confused about how * constructs the RURI when it generates a
BYE. For the situation where * send the initial INVITE it constructs the
RURI for the BYE from the contact header of the 200 OK response which is
well and good. However when * receives the initial INVITE it does not
use the contact header contained within to construct the BYE's RURI but
constructs it from scratch. This
2006 Jun 14
4
Using now() to determine what should be displayed
I''m trying to create a paginated list that will take note of the
"end_date" field in my table. This is what I have:
@post_pages, @posts = paginate(:posts, :per_page => 10, :order_by =>
''end_date'')
in the controller. And for the view:
<h1>Posts ending soon</h1>
<ul><% for post in @posts do %>
<strong>Post Title:
2006 Apr 06
4
using two foreign keys to the same table
i am working on a task manager with ruby on rails. it is my first major
project, so i''m still gettng my feet wet as i learn.
i''ve been trying to use the built in relationships to link my tables
together, but i''m not able to use the same naming conventions. for each
task, it has a field for the creator, and another field for the
assignee. both of these fields