Displaying 20 results from an estimated 10000 matches similar to: "Handling unexpected db exceptions..."
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
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 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
2
money data types
What data type is best for storing currency? I''m trying to come up
with a reliable cross-database solution for rails that is not too
complicated. Since I''m going to have currency fields all over the
place, I''m not so sure that using two integer fields for each amount
would qualify as uncomplicated. I''d like to be able to use database
functions like SUM to
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
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 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 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 Jan 30
5
Functional tests and dealing with login before_filter
Hi all,
I''m curious as to how you do functional testing on the controllers if, within
the ApplicationController, I have a before_filter :authorize, :except =>
:login, where the private authorize method checks for session[:user].
I can''t do "post :login", because that method is in a different controller.
I tried setting session[:user] directly in the setup
2005 Mar 06
3
permission error in rake''s clone_structure_to_test
Hello,
When I try to run "rake clone_structure_to_test" on my project, I get
the following errors:
$ rake clone_structure_to_test
(in /home/www/cedscreening)
psql:db/development_structure.sql:8: ERROR: permission denied to set
session authorization
psql:db/development_structure.sql:16: ERROR: permission denied for
schema public
psql:db/development_structure.sql:34: NOTICE: CREATE
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
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
2006 Jan 17
5
NOOB: Numeric only input...can it be done on client?
I was wondering if there''s a way to limit what a user is typing on the
keyboard to only valid numeric input. Is there a simple plugin or something
which would allow this? I guess with AJAX it could also be one. Has anyone
already solved this requirement? Thanks in advance.
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 Jan 18
5
NOOB Ajax question: handling form input
Hi,
I was trying to modify how a standard edit form works so I could use Ajax to
truncate a zip code field which became too long as the user is entering the
value. The form was generated by the generate scaffold script. The form is
filled with default data taken from the current record. I coded the
following changes to a field in the _form.rhtml file:
<%= text_field
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
2006 Dec 02
2
select some columns only when doing "find"
Hi,
I love ActiveRecord and its simplicity.
Person.find(1)
It''s so simple but imagine if the table people has 30 columns and there
are some columns with type ''bytea'' (or large object / binary data)
holding MB-s data, then you only need three columns only with type
''string'', ''string'', ''int''. It''s a waste of
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
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