Re: [Rails] Exchanging values of two records with unique-validated fields

2012-01-05 Thread Dmitry Suzdalev
On 5 January 2012 18:09, Peter Vandenabeele wrote: > If you mean "atomic" on the level of saving to the database > (all or nothing), you would need a database transaction. > > http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html > > Second, to circumvent the problem of t

[Rails] Exchanging values of two records with unique-validated fields

2012-01-05 Thread Dmitry Suzdalev
Hi fellows! Is there a way to atomically exchange values of records which are validated using 'validates_uniqueness_of'? Some details follow. Imagine I have a model: class Item < ActiveRecord::Base validates_uniqueness_of :weight end 'weight' is a sorting weight. I have an index.html view

[Rails] Re: How to access controller's instance variable in a js.erb loaded by javascript_include_tag?

2011-10-14 Thread Dmitry Suzdalev
Thank you very much, Frederick, very useful! I think I will go on with the first method (for starters)! :-) Cheers, Dmitry. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.c

Re: [Rails] How to access controller's instance variable in a js.erb loaded by javascript_include_tag?

2011-10-13 Thread Dmitry Suzdalev
And what if it is a large array of values?... Ok to pass them as a contents of the tag? I know I could do it with ajax request, but how do I pass this large amount of data when JS is disabled... What I'm doing is feeding data to jQuery Flot library. And it accepts data in place of a plot initializ

[Rails] How to access controller's instance variable in a js.erb loaded by javascript_include_tag?

2011-10-12 Thread Dmitry Suzdalev
Hello! In rails 3.1 app I have a controller UsersController with 'show' action. show.html.erb contains: <% content_for(:head) do %> <%= javascript_include_tag 'myscript' %> <% end %> Hello @user.name And I have this in myscript.js.erb $jQuery(document).ready(function() { alert(<%= @user.name %>

[Rails] Re: In Rails 3.1 Model.count() ignores :include - no outer join in generated SQL

2011-09-08 Thread Dmitry Suzdalev
Just for the record (in case anyone would search for the same thing): See this thread for more info: http://goo.gl/30nQF -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/

[Rails] Re: Method get of ActionController::TestCase ignores routes.rb?

2011-09-08 Thread Dmitry Suzdalev
Wow, that matcher works indeed! Thank you very much for analysis and for a solution! On Wednesday, September 7, 2011 7:51:08 PM UTC+4, Ruby-Forum.com User wrote: > > The following tests *do* work as expected: > > describe "GET 'contact'" do > it "should be successful" do > { :get => 'p

[Rails] Method get of ActionController::TestCase ignores routes.rb?

2011-09-07 Thread Dmitry Suzdalev
Hi! I'm running into issue which seems to indicate that ActionController::TestCase.get() method ignores what I have in routes.rb. Happens in 3.0.10 and 3.1.0 too. I have the following RSpec2 test of my XmlRpcController#index action: it "should get nothing in response to GET request" do get :i

[Rails] Re: In Rails 3.1 Model.count() ignores :include - no outer join in generated SQL

2011-09-06 Thread Dmitry Suzdalev
11 10:57:15 PM UTC+4, Frederick Cheung wrote: > > > > On Sep 6, 6:10 pm, Dmitry Suzdalev wrote: > > Ah, I see. > > Unfortunately I need exactly to call a count() method with left outer > join > > of another table > > If you want a join, why not us

[Rails] Re: In Rails 3.1 Model.count() ignores :include - no outer join in generated SQL

2011-09-06 Thread Dmitry Suzdalev
Ah, I see. Unfortunately I need exactly to call a count() method with left outer join of another table -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonra

[Rails] Re: In Rails 3.1 Model.count() ignores :include - no outer join in generated SQL

2011-09-06 Thread Dmitry Suzdalev
On Tuesday, September 6, 2011 7:12:05 PM UTC+4, Frederick Cheung wrote: > > From which version did you upgrade? > Upgraded from 3.0.10. Before upgrading I ran all of my tests to ensure they pass. After upgrading got a couple of test failures related to this issue... > Part of the problem with

[Rails] Re: In Rails 3.1 Model.count() ignores :include - no outer join in generated SQL

2011-09-06 Thread Dmitry Suzdalev
regression specific to Rails 3.1 and I should report this as a bug upstream If this is 2) I guess I should forward this to rails-core mailing list?... On Monday, September 5, 2011 10:11:24 PM UTC+4, Dmitry Suzdalev wrote: > > Hello! > > Just upgraded to Rails 3.1, ran my test and foun

[Rails] In Rails 3.1 Model.count() ignores :include - no outer join in generated SQL

2011-09-05 Thread Dmitry Suzdalev
Hello! Just upgraded to Rails 3.1, ran my test and found this issue: class Trade < ActiveRecord::Base has_many :transaction_trades . def Trade.do_something stale_trades = Trade.count('transaction_trades.id', :include => :transaction_trades,