[Rails] Migrations: Generate SQL instead of running the migration?

2011-05-09 Thread William Fisk
In a Rails migration is there a way to see what the generated SQL would be without running the migration? (A bit like we can do with Arel now by writing Model.where(:id => 5).to_sql ) William -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" gr

Re: [Rails] Re: Fast in MySQL console, slow in ActiveRecord

2011-02-25 Thread William Fisk
Yes I do. But still the problem is the difference in speed between running the query in the MySql console and using MySql2 gem. At the moment I think I might also be having a problem with a gem file. So slowly trying to remove them to see if I can see one causing a problem. -- You received

[Rails] Re: Fast in MySQL console, slow in ActiveRecord

2011-02-25 Thread William Fisk
Hi Fred, Yes I am pretty sure, because I write it out using to_sql before I run. At the moment is seems like a Windows memory problem rather than a ruby problem. As I commented on the StackOverflow thread I now have a solution for my immediate problem. Since I am calculating averages over a d

[Rails] Re: Fast in MySQL console, slow in ActiveRecord

2011-02-25 Thread William Fisk
Thanks, nice idea for installing ruby-prof. Never used it before and it's extremely easy to install and use. I'm on Windows so I needed to install with this command: gem install ruby-prof --platform=mswin32 -v 0.8.1 I tried it on a simpler query and I give the top lines of the profile here. Y

[Rails] Fast in MySQL console, slow in ActiveRecord

2011-02-24 Thread William Fisk
Has anyone experienced an ActiveRecord query being much much slower than running the equivalent query in the MySql console? I am running a simple "group by" query with one condition on a table with 7 million records. When I run EXPLAIN it says that it will have to scan over all the records - we

Re: [Rails] Limitations on parameters in routes?

2011-02-17 Thread William Fisk
Hi Peter, This works get 'places/:lat/:lng' => 'places#index', :constraints => { :lat => /-?[.\d]+/, :lng => /-?[.\d]+/ } I think it's just that the regular expression must match the whole text, and you were just missing the '+' at the end. William -- You received this message because you ar

[Rails] Re: Why use send when you can call the method directly?

2011-01-27 Thread William Fisk
Ah, thanks, yes that will probably be the reason. -- 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 rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsu

[Rails] Why use send when you can call the method directly?

2011-01-27 Thread William Fisk
I am reading through some code in active_record/relation/query_methods - def build_where (about line 230); and there are a couple of calls to send. Here's the first one [@klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))] and here's the second one attributes = @klass.send(:expan