Displaying 20 results from an estimated 10000 matches similar to: "select some columns only when doing "find""
2006 May 21
3
find with belongs_to -> belongs_to -> belongs_to
I have 3 tables
keywords (keywords attached to a file)
files (info about the file)
paths (path for the file)
[This is a legacy database, so I can''t change this]
keyword belongs_to file and file belongs_to path. Users need to be able
to search the keywords, but they only have access to certain volumes, so
the results need to be limited by the path. I also need to show paging,
2006 Jul 26
15
Rails without a primary key
I''ve been trying to use Rails on a database where the biggest
datawarehouse-style table doesn''t have a primary key. It really
doesn''t make sense and just adds extra unnecessary space. I do have,
however, a column that I normally use to search on (IP) that returns
many rows. The table also references several other tables through
rails-friendly foreign keys.
Simple AR
2006 Jul 21
3
[Slightly OT] CSS with wildcard?
Sorry if this is a simple question, I''m a CSS noob.
I have a rails app that is displaying posts, I am having it generate
each post with its own div like "post_19", "post_20", etc.
I could make it so it puts another div around that div (i need the
individual post div''s for deletion with AJAX) but would rather not.
Is there some way to use CSS to do
2007 Aug 07
4
Howto use ENCRYPT() function of MySQL
Hi all,
I''m working actually on a Control Panel to manage a mail system.
Until now, when I create a new mail account, i do an insert and protect
the pasword with ENCRYPT(''password'') function.
I can''t change the method to SHA1 or MD5 because the SMTPd a IMAPd will
not support it.
Can you explain me how to force RoR to rewrite the INSERT SQL query and
use
2006 Jul 25
2
Losing precision while copying interval type data (Postgres)
Hi
I am trying to use active record to copy some data. One of the entry I
am copying is type interval (Postgres); however, it lose some precision
after I copied that column.
Here is what I did:
@newData.elapsedtime = @oldData.elapsedtime
@newData.save
Result:
both displayed as 00:00:02.453 in the table, however, if I use the
following command to convert its value into float
( SELECT
2006 Jun 21
3
Simple range question
I have a model with a datetime field called start_date. I''d like to do
a find on the model so that it returns only records with the start_date
equal to the current day.
Something like this:
@foos = Foo.find(:all,
:conditions => //?? start_date equal to today''s date
??// ] )
Thanks in advance for any help.
-------------- next part
2006 Jan 19
2
NOOB: Using locals to pass data to a SQL query
I want to show a users entries based on there login id. I have tried
this:
View:
<div id="myfish">
<%= render :partial => ''myfish'', :locals => {:user => session
[:user].id } %>
</div>
Partial:
<% for entry in @entries %>
<table border ="0" CELLSPACING="0">
<tr class="<%= alternate
2007 Jul 31
3
country listbox from table
sorry again,
i''m building a registration form, getting stumped on the country
listbox.
any ideas how i could build a listbox for countries, taking it''s content
from a data table?
i''d imagine i''d have to generate a data model for country, fill it in
with all the current ISO spec countries; that i can do.
then tie that data model to the account controller.
2007 Oct 09
5
Backticks wrapping SQL values in polymorphic associations...
Hopefully the subject line didn''t scare you. That said...
I have a simple polymorphic relationship (is that possible?):
class Part
has_many :attachments, :as => :attachable
end
class Attachment
belongs_to :attachable, :polymorphic => true
end
Calling Part.find(:first).attachments yields this SQL error:
ActiveRecord::StatementInvalid:
Mysql::Error: Unknown column
2007 Jul 09
5
Color coding table rows depending on an attribute
I need to show a different background color depending on the type of
comment posted. The type of comment is determined from a drop-down
selection. I figured the simplest way would be to do something like I
have below, but I can''t seem to get it to work:
<tr <%= puts ''"style = "background: red;"'' if comment.comment_type ==
''Hiring
2007 Oct 12
1
database configuration specifies nonexistent postgresql adapter
Hi
I am trying to get RoR to work with Postgresql 8,2.5 (latest stable
version)
Steps taken
1. Download Postgresql 1.82 and installed successfully
2. Edited my Database.yml
development:
adapter: postgresql
database: test_development
username: postgres
password: xxx
host: localhost
test:
adapter: postgresql
database: test_test
username: postgres
password: xxx
host: localhost
2006 Jul 14
3
postgres migration notices
When I run "rake" using a postgres 8.1 database, I get a bunch of these notices.
NOTICE: CREATE TABLE will create implicit sequence
"categories_id_seq" for serial column "categories.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"categories_pkey" for table "categories"
How can I avoid those? I take it I need to modify the
2007 Jun 19
2
sequence name prefix
In Postgres, I use different database schemas for each application, by
declaring, e.g.:
class ApplicationController < ActionController::Base
ActiveRecord::Base.table_name_prefix = "keywords."
end
I assumed that the sequence names were also prefixed with the database
schema names, e.g.
keywords.things_id_seq
But Rails 1.2.3 assumes the sequence is *NOT* in the same schema as the
2006 Jun 24
8
PostgreSQL on Mac?
Is there something like MAMP, but uses PostgreSQL instead? I found a
couple PostgreSQL dmg''s, but one was < 8.x. For those who use PostgreSQL
on Mac, how''d you install it (fink, package, please don''t say compile!)?
Thanks,
Joe
--
Posted via http://www.ruby-forum.com/.
2007 Oct 15
6
SQL injection with :order, :limit, :group
I know how to avoid SQL injection attacks when you use :conditions
User.find :first, :conditions => ["login=?", params[:username]]
but how about with :order, :limit or :group?
# uh-oh...spaghetti-oh
User.find :first, :order => "login; delete from users; select * from users"
Pat
--~--~---------~--~----~------------~-------~--~----~
You received this message because you
2007 Jul 19
8
Where do I put code for my own types?
Sorry for all the questions today...
Beyond the obvious things--models, controllers, helpers, and other
framework-related types--where should I put the code for my own types?
For example, I was thinking of writing my own AJAX-friendly paginator,
but I don''t know where to put the code for that sort of thing.
I would prefer to keep things object-oriented, so I would rather do a
lot of
2006 Feb 27
5
Localization: word wrap in tables?
I am a Rails noob, working on bringing a legacy db system into the 21st
century. I want to localize the UI for two languages (EN/JA). Since I
am already using the salted user system, I have been playing around with
T. Fuchs'' localization module. Nice and simple, already up and working.
But here''s the problem: Japanese text is wrapping weirdly in table
cells. I could set
2006 Jul 03
13
Remote Postgres is driving me crazy!
Hi guys,
I need your help. Here is my database.yml:
development:
adapter: postgresql
database: db
username: username
password: mypassword
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn''t need configuration. Windows does not
have
# domain sockets, so uncomment these lines.
host: 192.168.22.1 (this is a remote ip in
2006 Feb 28
10
Salted hash login, postgresql, unit tests
Hello,
I have tried to install the salted hash login generator by following the
quick start guide at:
http://wiki.rubyonrails.com/rails/pages/SaltedLoginGeneratorQuickstart.
Everything seems to work fine until I try to run the unit tests by doing
''rake test_units'', then I get the following error message:
<error-message>
[brasse@keso login-test]$ rake test_units
(in
2006 Jan 17
30
MVC design good/bad
I am curious what you find is good and bad MVC design.
Let''s use the find and find_by_sql methods as examples.
Currently I have these spread out all over the place...
View: here I have some find methods when I am for example populating a
select list with choices in a form.
Controller: here I have the simpler find methods.
Model: here I have the more complicated find methods (usually