[Rails] Re: ror models relations - advice ?

2010-09-24 Thread Raja Venkataraman
Not sure if you noticed the typo. Its ActiveRecord::Base (the d was missing in the answerer's post). -- Raja Helder Oliveira wrote: radhames brito wrote: class Game ActiveRecor::Base has_many :teams class Team ActiveRecor::Base belongs_to :game call designation of a game like

[Rails] Re: Named scope in named scope ??

2010-09-23 Thread Raja Venkataraman
Adrien Nom wrote: Hi, I would like to return a combination of named scopes in a named scope : For example, I have a named scope filter and I want to add a named scope eval_filters like Product.eval_filters(['x','y','z']) is equivalent to Product.filter('x').filter('y').filter('z')

[Rails] Re: conditional show action

2010-09-23 Thread Raja Venkataraman
badnaam wrote: How can I render a show action on certain conditions? def show @post = Post.find_approved if @post.approved approved = true end respond_to do |format| # I only want to render show.html.erb if approved is true if not I would like to redirect the user back

[Rails] Re: superclass mismatch for class Tempfile

2010-09-22 Thread Raja Venkataraman
Rodrigo Felix wrote: I've been facing a problem when generating a model (or controller, ...). I'm using rails 2.3.8 and ruby 1.8.7. Has anybody been facing anything like this? Do you have 2 instances of TempFile (tempfile.rb) or DelegateClass (delegate.rb) ? Googling around seems to suggest

[Rails] Re: Find last record updated

2008-10-05 Thread Raja Venkataraman
Abel wrote: I always get confused when I have to make a search with Active Record a little beyond the most ordinaire. How do I find the record that was updated the last? It has to be something like Ad.find :conditions = updated_at = :last How about Ad.find :first, :order = 'updated_at

[Rails] Re: count number of lines in a file with file.open

2008-10-05 Thread Raja Venkataraman
Hmm, not sure what you are missing, seems fine to me. irb(main):001:0 f = File.new('test.txt') = #File:test.txt irb(main):002:0 f.each_line do |line| irb(main):003:1* w = line.split(' ') irb(main):004:1 puts w irb(main):005:1 end First Second Third = #File:test.txt My file had First, Second

[Rails] Re: change event in one combo box to update another combo bo

2008-10-05 Thread Raja Venkataraman
Jay Pangmi wrote: Hi, I have two combo boxes. One combo box has the name of countries stored in the database. So, when a country is selected from this combo box I want other combo box to list all the cities stored in the database related to that selected country without clicking any button.

[Rails] Re: problem with auto_complete!!

2008-10-05 Thread Raja Venkataraman
Couple of things a) Your stylesheet is called complete.css but your stylesheet_link_tag says example ? b) Check your logs as you type to see if rails fires off queries depending on your input.. The autocomplete method is doing a find which should be firing off SQLs in ur log file. You would

[Rails] Re: Helper methods from controller

2008-10-05 Thread Raja Venkataraman
Jon Stenqvist wrote: Hi, I'm not sure i'm my design is correct, but i have around_filter in the controller, where i want to add a small javascript at the end of the page. Is there someway i can use the javascript_tag from the controller? i though there where a helpers proxy available.