similar to: Model based in a query

Displaying 20 results from an estimated 100000 matches similar to: "Model based in a query"

2006 Nov 30
0
Query string based on the selection in HTTP POST
I want to generate the query string based on the options selected. For example it could be www.test.com/search?id=1 or www.test.com/search?id=1&zip=60008. How could I achieve this using http::POST? I tried the following, which didn''t work url = "{''id'' => 1, ''zip'' => 60008}" res =
2007 Mar 13
13
validates_inclusion_of disabling
Hello all. I have a problem using validates_inclusion_of. I need to switch off some validations during a migration period, is there a way? I tried to use if, with a static method of one of my models, but the behaviour is something strange It seems that the static method should be in a string to be evaluated. And the order of the elements in the if is counting... :if => (:some_field
2008 Feb 09
0
MVC interplay to query multiple models
I''m trying to track down why I''m getting close to desired output, but not quite. It looks like the webpage sorta-kinda is grabbing the right data. For instance, there are three Login objects which should be showing and it looks like the show is grabbing three objects, so that fits, to a degree. However, it''s just grabbing the hexadecimal object id, and not
2006 Nov 19
1
How to create a SQL query without ActiveRecord?
I want to write an independent (not model-related) SQL query for some statistic information in an online shop system. So I know I could grab all users with ActiveRecord and then just count the array size, but that would massively waste resources. And I also want MySQL to do some max, min and average calculations. So is there a way to issue a query and get the result set without models being
2008 Feb 04
1
How does craigslist retain search query results?
When you search for a keyword on craigslist, a list of posts is returned. When you click on an individual post in that list, the full post is displayed. Then, when you press the back button on your browser, the results list is displayed again, without the server having to query again for the list of keywords. How can I get the server to remember search results without having to requery the
2008 Nov 10
2
Sort model based on max value of has_many field
Hi, I have models such as: class Team < ActiveRecord::Base has_many :games end class Game< ActiveRecord::Base belongs_to :team end So there are many (well, 0 to 6) games for each team. Team game has a "score". I would like to get a list of the teams, sorted by the highest scoring game - sort of a ranking based on highest score. I''ve tried several cominations of
2007 Mar 07
0
Map :join query into model objects
Hi, how can I map: :joins => "LEFT OUTER JOIN stocktbl ON stocktbl.stock_id = artisttbl.stock_id" into a stocktbl model object? -- Regards Andrew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2006 Nov 16
3
MySQL query optimization
We have created a Ruby on Rails website which is based on searching a table of 70,000+ object. Each object searched then returns a list of id''s in another table, of about 30,000. The id''s are listed for each object in the first table. The problem is, when we search for object which are very frequently met, the query runs extremely slowly, and after looking at the query log,
2006 Nov 08
4
writing SQL query WHERE.. IN.. anArray ?
I have an array @dpt_ids ex : @dpt_ids = ["43", "48", "49", "50", "51"] I try to insert it into my sql query to be used in a ''find_by_sql'' query = "SELECT * , #{kms} AS km FROM cities" query << " WHERE department_id IN ( #{dpt_ids} ) " but this transform my array into a unique string :
2008 Nov 19
3
Rails.cache and problem with model id?
I have the following: MODEL: def self.get_tag_cloud Rails.cache.fetch(''fetish_tag_cloud'', :expires_in => 1.hour) do find(:all, :conditions => [ "approved_for_tag_cloud = true"], :order => "LTRIM(name)") end end CONTROLLER: def index @fetishes = Fetish.get_tag_cloud end VIEW: .... <% @fetishes.each do |fetish| -%>
2007 Dec 13
3
run sql query ?
hi i''ve got one action which i want it to perform a sql update query. how can i just run a sql query within my rails app? e.g. def @sql = "update ...... from mytable" execute @sql redirect_to :action => ''list'' end any ideas? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message
2006 Dec 05
5
Render :update and script tags
Hi All! I''m kind of new o ruby so please apologize my stupid questions on advanced... I''m using render :update do |page| page.replaca_html :element , :partial => ''apartial'' end This is working well, since I see in the page the following code: try { Element.update("element", ""); } catch (e) { alert(''RJS
2007 Aug 26
2
Multi-word query searching across columns
I''m trying to implement a basic name search on a People table with separate first_name and last_name columns. I am using the will_paginate plugin and have the following search method in the model: def self.search(search, page) paginate :page => page, :conditions => ["lower(last_name) like ? or lower(first_name) like ?",
2007 Mar 08
2
Rendering a view from a model
Hi peoples. I have the following class method in a Rails model, in which I retrieve some objects from the DB... @bubbles = Bubble.find(:all, :limit => 30) # What is the limit? open( "public/xml_data/main_data_feed.xml", "w" ) { | l | l.write ERB.new( IO.read( File.join( RAILS_ROOT, "app/views/rssfeed/bubbles.rhtml" ) ) ).result } When I attempt to run this
2007 Jan 26
6
has_many :through query question
I think this is obvious. but for some reason I''m not getting it. Models: Bicycles, Accessories Join Model: Upgrades The idea is that you can upgrade your bike by adding an accessory, and the upgrade price is often less than the accessory price would normally be. So the Upgrades table has id, bicycle_id, accessory_id, and price. class Bicycle has_many :upgrades has_many
2007 Aug 05
1
Activerecord Query Generation
Is there a way to just retrieve the sql that would be generated by an activerecord call without actually executing the call? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2008 Jun 13
2
Rails 2.1.0 - find with :include and missing JOIN in SQL query
Hi, We''re trying to rewrite veeeery old Rails app that we successfully managed to move to 1.2.6 and now we''re trying with 2.1.0. One of the problems is caused by :include in AR.find. Rails 1.2.6 generates totally different SQL query than 2.1.0. Here''s Rails find query and generated SQL queries: Foo.find(:all, :include => :ticket, :conditions =>
2007 Jul 23
1
How to do link_to with query parameter AND css class
Folks, I''ve been trying to get a number of variations of the following line of template code to work: <%= link_to ''Show contact details'', :controller => ''people'', :action => ''show'', :class => ''actionLink'', :id => person %> I''ve tied putting curlies around the controller and action as well
2007 Sep 29
2
REXML - XML query only returning one (last) result
I''m really new to Ruby on Rails, and I''m trying to read an XML file with REXML. No matter what I try, I am only getting the last result returned from my query. I should be getting 365 results. Here is the code: include REXML require ''rexml/document'' require ''rexml/xpath'' class MakeFootprintController < ApplicationController def index
2006 Dec 13
6
triggering a query within a loop
Any help with this would be very appreciated, I''m completely new to rails. I''m building an application that''s looking to do the following: First off i''m trying to convert my site from ColdFusion to RoR, this is the site: http://www.walkenclips.com/ It''s one page that basically does this: Query the db to get a list of movies (movies table) Loop