similar to: Avoiding SQL Injection in :order?

Displaying 20 results from an estimated 1500 matches similar to: "Avoiding SQL Injection in :order?"

2007 Sep 05
4
Mocking to spec a sort_by method
Hello, I have a question regarding the use of Mocha with rSpec to spec one of my methods. My spec contains the following vehical1 = mock() vehical2 = mock() vehical1.stubs(:mph).returns(150) vehical2.stubs(:mph).returns(250) comparer.add_vehical([@vehical1, @vehical2]) comparer.sort_by(:mph) The comparer is an object that has a basic "stack like" functionality, add_vehical is the
2006 Jul 20
3
sort_by with via a parent models child
I am having a problem with ruby''s sort_by function. I want to sort a list of parent model objects based on the children of the parent models. Normally you might say sortedList = modelList.sort_by { |model| model[''someAttribute''] } What I am tring to do is sortedList = modelList.sort_by{ |model| model.children.find(:first, order=>"price desc" ).price}
2006 May 02
4
ordering after a inject
Hi, My results are getting out of order after I do the following command: count = result.inject({}) { |hsh, row| hsh[row[''name'']] = row[''count''].to_i; hsh } Why? Here are more specifics: My complete method is this (based off of acts_as_taggable code - not'' DHHs, but the original one): def self.sql_to_count_plays(lookback) sql =
2006 May 14
4
searching on foreing keys
Hey all, I''m using a simple search function. It''s working great except for foreign keys. I have one table pets (id,name,owner_id) and another table people(id,name) owner_id being a foreign key of pet pointing to people name. here it is on the pet controller: @paginator, @pets= paginate(:pets, :conditions =>["name OR owner_id like
2009 Jan 13
1
ROR - Excel Export Example
If you are running on Windows you can use create and read speadsheets using the ''win32ole'' require This sample should give you the basic idea ------ def export require ''win32ole'' @sort_by = ''last_name'' current_user = ''steve'' @records = Contact.find( :all, :conditions =>
2006 Jan 10
1
sql server freetds/odbc question
I''m having an error from Linux via freeTDS/ODBC to SQL Server with cod that runs fine against SQLite and MySQL. Here''s the code: def find_recipes_for_workorder_by_id @recipe_pages, @recipes = paginate_with_sort :recipes, :per_page => 10, \ :conditions => ["recipe.workorder_id = ?", params [:workorder]] render :template =>
2008 Sep 17
13
Capturing the sql from a statement without executing it?
Hi guys, Is there an elegant way to capture the sql that would have been executed by an ActiveRecord statement, without actually executing it? :) I''m imagining something like sql = User.find(1).groups.to_sql or perhaps sql = ActiveRecord::Base.capture_sql { User.find(1).groups } resulting in sql = ''SELECT * FROM groups INNER JOIN memberships.... WHERE users.id =
2012 Mar 28
4
Hash iteration order in a template not consistent
Hi, I did some basic googling, but didn''t find an answer yet. I am sorry if this is a FAQ. In a manifest for creating an Apache config file, I define a hash like this: $aliases = { ''/foo/'' => ''/home/foo/www/'', ''/bar/'' => ''/home/bar/www/'', ''/baz/'' =>
2008 Mar 28
6
Eager Loading + Confusion
So I''m trying to do a find with an order by specific column values thing, but some of the columns are attributes through associations. So I did some eager loading with the :include option to try and access the attributes of the object I''m doing the find on. Stuff has been blowing up on me so far. Here''s the code in the controller right now: sort_by = params[:sort_by]
2006 Jan 10
1
sql server & linux: left join problem
I''ve got a left join problem of some sort connecting from linux FreeTDS/ODBC to SQL Server. It''s similar to the false post I had earlier, but this is a real problem. Here''s my code: def find_recipes_for_workorder @recipe_pages, @recipes = paginate_with_sort :recipes, :per_page => 10, \ :joins => ''left join workorder on
2012 Sep 10
3
How to remove last comma when iterating through hash in erb template
I need to produce a line in a config file in the format x = "ip1,ip2,ip3" I am using the method below to sort the hash before iterating over it. However, as you can see there will always be a final comma which breaks the app that uses this config file. Does anyone know how I could remove the final comma? ipv4_bind_addresses = "<% routes.sort_by {|key, v| key}.each do |key,
2006 May 24
0
ActiveRecord::Base.sanitize_sql and SQL injection vulnerability.
Hi The PostgreSQL development group released an update[1] for PostgreSQL to address a SQL injection vulnerability. From the infromation[2] released with this update, it appears the vulnerability exists in other (all?) database systems allowing multi-byte encoding of requests. Of particular importance - since it relates not to database issues but to web programming practices - are these quotes
2018 Jan 19
1
Web scraping different levels of a website
Hey Ilio, I revisited the previous code i posted to you and fixed some things. This should let you collect as many studies as you like, controlled by the num_studies arg. If you try the below url in your browser you can see that it returns a "simpler" version of the link you posted. To get to this you need to hit F12 to open Developer Tools --> go to Network tab and click on the
2006 Mar 28
2
Testing STI models
Hi everyone! I have a question: what is the preferred way (in terms of simplicity) to test models with single table inheritance. Right now I have 1 test case and 1 fixture for all of the STI models, but it''s very hard to maintain it (too many tests and records in fixture). It would be better if fixtures could be named separately from DB tables. I know, Engines plugin has
2006 Feb 19
2
progressive updates
I have a list view and have it sorting the data presented in the list view by clicking on the top of the column - that works fine. Now, I want to add a pop up-list which controls 3 different levels of record select to be presented in this list... - ALL - placement.discharge_date IS NULL - placement.discharge_date IS NOT NULL I can have 3 different ''methods'' and
2010 Sep 22
1
Bundler picking up wrong version of Ruby with Rails 3 ( possible bundler bug )
Hello All, I am developing a JRuby on Rails 3 application. Standard stuff. I am facing problems getting autotest to run. Here''s the trace: % autotest loading autotest/rails_rspec2 bundle exec /Users/manish/Foo/Foo-Server/jruby-1.5.2/lib/ruby/gems/1.8/gems/rspec-core-2.0.0.beta.22/bin/rspec
2008 Aug 23
1
Route segment ":controller" cannot be optional because it precedes a required segment.
Hi, With this route... map.namespace :admin do |admin| admin.sort ''/:controller/sort/:sort_by/:sort_dir'', :action => ''sort'' end ...I get this message... Route segment ":controller" cannot be optional because it precedes a required segment. This segment will be required. The route works as expected, but the warning is worrying. Any ideas?
2006 Aug 02
2
Ajax_Scaffold display from link table
Hi, Ive followed the pets/people ajax_scaffold example without any problem. I have a table documents and each document has a category. In the documents table i have a field called category_id. So in the documents grif i want to display the corresponding catgory name and when it comes to adding a new category or editing the have a drop down list to select from. category.rb require
2006 Nov 04
8
alternatives to script/runner?
I''ve been using script/runner to add and delete files from the database in response to inotify events. This works in theory, but is too slow to keep up with a large number of events in succession; I''m suspecting that the bottleneck is that script/runner has a huge startup cost. One thing I thought of was to queue inotify events, and call script/runner once a minute to clear the
2006 Feb 08
7
DRY methodology
because I am a grasshopper... Now that I can sort my ''list''...is there a logical way of not repeating myself to having essentially the same list view with multiple sorts? i.e. def list_cl # ordered by clients last name @placement_pages, @placements = paginate( :placements, :include => [:client], :order_by =>