similar to: NOOB: Using locals to pass data to a SQL query

Displaying 20 results from an estimated 2000 matches similar to: "NOOB: Using locals to pass data to a SQL query"

2006 Jan 19
8
I can''t figure out how to solve this one
I am creating an application to run a fishing tournament (see http:// www.ruby-forum.com/topic/51209 for a little background) Now I am running into an issue trying to calculate a leader board. each participate can enter multiple fish but only the largest fish per a given species counts towards the overall score. My entries table looks like this:
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 Jan 10
0
find_by_sql + partials question
Ok now that I have find_by_sql love working for my "Top 10 List" I want to make them a bit more DRY. Tis is what I have so far: Model: def self.topfish find_by_sql["select species.name, length,species.multiplier*length as score,caught_on from entries join species on species_id = species.id where species_id = ? order by score DESC LIMIT 10", species]
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 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 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
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.
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 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 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 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 16
1
Handling unexpected db exceptions...
Is there any general way, other than putting in "rescue" catch sections, to capture exceptions thrown when an unexpected exception is thrown? Thanks in advance, James -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060116/6c2f4bb9/attachment.html
2006 Jan 12
0
[file_column] Problem displaying images after upload
This is the last major hurdle in my little app and I can''t seem to figure it out. I am using file_column to upload images. The upload (and rmajick goodness) works just fine, but when I try to display the resulting image I get this error: undefined method `image_relative_path'' for #<Array:0x252b694> In script/console I can do this however:
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
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
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
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
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
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