[Rails] Re: dump and import MySQL table w/ accents
Wisccal Wisccal wrote: > Jeffrey L. Taylor wrote: > > As far as I understand, utf8_general_ci is case-insensitive. I meant to say "accent-insensitive"... -- 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: dump and import MySQL table w/ accents
Jeffrey L. Taylor wrote: >> The string column is utf8_general_ci collation, ... As far as I understand, utf8_general_ci is case-insensitive. Maybe, you want to give utf8_bin a shot. mysql> create table t(i int, v varchar(10) collate utf8_general_ci, constraint t_pk primary key(i, v)); Query OK, 0 rows affected (0.00 sec) mysql> insert into t select 1, 'jose' union all select 1, 'josé'; ERROR 1062 (23000): Duplicate entry '1-josé' for key 1 mysql> drop table t; Query OK, 0 rows affected (0.00 sec) mysql> create table t(i int, v varchar(10) collate utf8_bin, constraint t_pk primary key(i, v)); Query OK, 0 rows affected (0.00 sec) mysql> insert into t select 1, 'jose' union all select 1, 'josé'; Query OK, 2 rows affected (0.01 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> select * from t; +---+---+ | i | v | +---+---+ | 1 | jose | | 1 | josé | +---+---+ 2 rows in set (0.00 sec) -- 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Asking for help with operating on data
eggman2001 wrote: > I have a few thousand rows of stock market data - one row for each > day. I'm using ActiveRecord to perform database operations. > > I'm interested in performing a calculation on each row while > incorporating the result of the calculation on the previous row, and > then once the calculation has been performed for all rows, perform a > new calculation that uses the individual calculations of each row. > > I figure that I'll start with an array of size 3,000. Then I would > probably want to iterate over it, possibly saving the result of the > operation of each row to a new array but this area is a little foggy. > > Any suggestions? Assuming you want to calculate something like percent change for each day, you could load the entire result set into an array, and then do something like: changes = @stock_data.each_with_object([]) do |data, array| last_value = array.last.value change = (data.value - last_value) / last_value * 100 unless last_value.zero? array << [data.transaction_date, change] end -- 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: What's the best way to run (many) complex queries in a rake task ?
> Just for curiosity sake, I have an index on [viewer_id, viewer_type, > content_id] Maybe, you want to include the rate in the index as well? That way, everything is in the index, and I would presume, MYSQL will not have to access the table at all. -- 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: share controller/table
Armen Arevian wrote: > I'm building a type of CMS and have a question about sharing code/ > tables. So i have a typical blog setup with a 'posts' controller > which has many comments. I need to also make an 'article' controller > which is similar to posts but different enough that it needs its own > controller. Comments though will work exactly the same. Rather than > remake the comments table/code (i.e. 'article_comments' controller), > i'd prefer to just share the general comments controller/table. Is > there a way to do this? Hi Armen I think you should look into polymorphic associations. Something along the lines of: class Comment < ActiveRecord::Base belongs_to :attachable, :polymorphic => true end class Post has_many :comments, :as => :attachable end class Article has_many :comments, :as => :attachable end should work. Check out the API at http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html -- 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Problems with Rails and Postgres
Rafael Roque wrote: > Hi all, > Have you looked at the SQL generated in the log directory? -- 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: saving mutliple objects to database
Adam Akhtar wrote: > If i create in memory a hundred or so instances of a model, how do i go > about saving them to the database. > > I have a Task Model > > and say I have an array of Task obects > > @tasks = [...] > > how do i save them > > do i > > @tasks.each do |task| > task.save > end > ? What you can do is use the Model#create class method. You will have to instantiate hashes of properties instead of model objects, though. Like: tasks = [{:name => 'Go shopping', :date => Time.now},{:name => 'Get a haircut' => 1.day.from_now}] #etc Task.create(tasks) -- 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: uninitialized constant ActionView::Helpers::AssetTagHelper
johnrails wrote: > I've made some progress since this post. I've installed ruby and > rubygems from source, and now when i run rake i get this error: > > Rails requires RubyGems >= 0.9.4 (you have ). Please `gem update -- > system` and try again. > > For some reason boot.rb can't find which version of rubygems i have > installed, but i have 1.3.1 installed. > > Has anyone else experienced this? > > Thanks, > John It sounds like you have two gem versions in your path. What does the output of "gem env" give you? -- 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---