[Rails] Built in (boolean)? method

2011-06-03 Thread Ants Pants
When creating a boolean attribute in ActiveRecord, you get a ? method for free. Sadly, it's returning false for a true value. Does anyone know what might be going on? >From my console (for_charity: true). Same behaviour on Rails 2.3.8 and 2.3.11 ruby-1.8.7-p302 > m.for_charity? => false ruby-1.8

[Rails] has_many belongs_to in multiple tables

2011-06-03 Thread rajeevkannav
My model association looks like this class User < ActiveRecord::Base has_many :correlations has_many :roles, :through => :correlations has_many :skills, :through => :correlations end class Skill < ActiveRecord::Base has_many :correlations has_many :roles, :through => :correlat

[Rails] Re: Stupid newbie question

2011-06-03 Thread gnarmis
Hmm, I wrote my replies assuming it was Rails 1.2.6. If your app's Gemfile has that info, it pretty much is Rails 3.0.3. In that case, try installing rvm, and then... rvm install 1.8.7 rvm install 1.8.6 Now you can experiment with both versions of ruby. To use a specific one, rvm use 1.8.7 (to

Re: [Rails] There must be a more elegant way to do this

2011-06-03 Thread Conrad Taylor
On Fri, Jun 3, 2011 at 9:49 AM, skt wrote: > Hello, > > I have a bunch of arrays containing records retrieved from the > database in separate queries. That can't be changed - I have deal with > the different arrays of these records. Each of these records contains, > amongst other data fields, two

Re: [Rails] Re: Creating common method in application ontroller

2011-06-03 Thread Gordon Yeong
Monkey patches are evil. On Jun 4, 2011 3:42 AM, "Michael Pavling" wrote: > On 3 June 2011 18:34, Kevin wrote: >> Out of curiosity what should one do if one wants to have a method inherited >> by all models? > > You can monkey patch Object or Class if you really want... > > # patch in environment

[Rails] Re: There must be a more elegant way to do this

2011-06-03 Thread skt
On Jun 3, 1:39 pm, Valery Kvon wrote: > Well, that's other one task and not just .uniq. Magic unuseful :) > > You'd better to write much more complex clause: > > (array1 + array2 + arrayN).group_by { |instance| [instance.user_id, > address_id] }.values.collect { |array| array.sort {|a,b| a.dist

[Rails] Re: Stupid newbie question

2011-06-03 Thread Sta Canovist
On Jun 3, 9:19 pm, Norm Scherer wrote: > This tells you what rails is installed on your system (at least what is > in your path).  The real question is what rails version the application > is running with on the target system wherever that is.  You need to run > 'rails -v' on that system or look i

Re: [Rails] Re: There must be a more elegant way to do this

2011-06-03 Thread Valery Kvon
Well, that's other one task and not just .uniq. Magic unuseful :) You'd better to write much more complex clause: (array1 + array2 + arrayN).group_by { |instance| [instance.user_id, address_id] }.values.collect { |array| array.sort {|a,b| a.distance <=> b.distance}.first} On 04.06.2011, at 0:13

Re: [Rails] There must be a more elegant way to do this

2011-06-03 Thread Colin Law
On 3 June 2011 17:49, skt wrote: > Hello, > > I have a bunch of arrays containing records retrieved from the > database in separate queries. That can't be changed Why? I suspect you could do what you want much more easily using ActiveRecord to get the data for you directly. Assuming you have Ac

[Rails] Re: There must be a more elegant way to do this

2011-06-03 Thread skt
Thank you all for your suggestions. My apologies, I should have mentioned this before but I thought once I figure out how to get uniq records based on combination of user_id and address_id I could figure out the rest. Essentially amongst other fields, each of these records contains a computed dist

Re: [Rails] There must be a more elegant way to do this

2011-06-03 Thread Tim Shaffer
On Friday, June 3, 2011 3:09:55 PM UTC-4, pavling wrote: > > On 3 June 2011 19:19, Tim Shaffer wrote: > > I think the problem with doing that is that the arrays contain instances > of > > models. > > I .uniq arrays of instances of models all the time - it's a very handy > tool. > Agreed, but it

Re: [Rails] Re: Stupid newbie question

2011-06-03 Thread Norm Scherer
On 06/03/2011 10:00 AM, Sta Canovist wrote: On Jun 3, 6:54 pm, Hassan Schroeder wrote: You seem to be mixing up commands between Rails 2.x and 3.x. Which do you have installed? Or more to the point, what is the app you're trying to run based on? Well If I type rails -v (I guess this is the righ

Re: [Rails] There must be a more elegant way to do this

2011-06-03 Thread Michael Pavling
On 3 June 2011 19:19, Tim Shaffer wrote: > I think the problem with doing that is that the arrays contain instances of > models. I .uniq arrays of instances of models all the time - it's a very handy tool. >> u1 = User.first => # >> u1.object_id => -614919958 >> u2 = User.first => # >> u2.object

Re: [Rails] Re: There must be a more elegant way to do this

2011-06-03 Thread Michael Pavling
On 3 June 2011 19:30, Valery Kvon wrote: > Try pass the block: > > (array1 + array2 + arrayN].uniq { |instance| [instance.user_id, > instance.address_id]} > > undocumented feature nice. Or if you only want those two fields: (array1 + array2 + arrayN).map{|instance| [instance.user_id, instance.

Re: [Rails] Re: Stupid newbie question

2011-06-03 Thread Noel
There's probably going to be lots more pain related to any gems used in that app. All in all seems like about time that app get some serious love and get updated at least to Rails 2.3 Ruby 1.8.7 On Fri, Jun 3, 2011 at 11:49 AM, gnarmis wrote: > After using RVM with ruby 1.8.6, try also doing g

[Rails] Re: There must be a more elegant way to do this

2011-06-03 Thread skt
Thanks Michael and Tim. On Jun 3, 11:19 am, Tim Shaffer wrote: > I think the problem with doing that is that the arrays contain instances of > models. > > Sounds like skt wants to consider an instance unique based on only two > attributes of each instance. That's correct Tim - I am looking to un

[Rails] Re: Stupid newbie question

2011-06-03 Thread gnarmis
After using RVM with ruby 1.8.6, try also doing gem installs with lower versions of the gems you're installing. If macports is giving u trouble, uninstall macports. Install Homebrew . If

[Rails] Re: Stupid newbie question

2011-06-03 Thread gnarmis
Oh, also, here's a trip down memory lane: http://weblog.rubyonrails.org/2007/1/19/rails-1-2-rest-admiration-http-lovefest-and-utf-8-celebrations -- 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 h

[Rails] Re: Stupid newbie question

2011-06-03 Thread gnarmis
Btw, the current, preferred way of getting pretty much all formulas is Homebrew . Clean, easy, simple. Also, I was gonna upvote the RVM recommendation until I realized...yeah... try: 1. install RVM and don't use 1.8.7

[Rails] Re: Stupid newbie question

2011-06-03 Thread Sta Canovist
On Jun 3, 8:29 pm, Hassan Schroeder wrote: > I believe you're doomed  :-) > > Seriously, this has massive pain written all over it; 1.2.6 is ancient. > > If I were you, I'd find someone who knows Rails, let her/him log into > the test server you previously mentioned and clone the environment > the

Re: [Rails] Re: There must be a more elegant way to do this

2011-06-03 Thread Valery Kvon
Try pass the block: (array1 + array2 + arrayN].uniq { |instance| [instance.user_id, instance.address_id]} undocumented feature On 03.06.2011, at 22:23, skt wrote: > Thanks Michael and Tim. > > On Jun 3, 11:19 am, Tim Shaffer wrote: >> I think the problem with doing that is that the arrays c

Re: [Rails] Re: Stupid newbie question

2011-06-03 Thread Hassan Schroeder
On Fri, Jun 3, 2011 at 10:00 AM, Sta Canovist wrote: > Well If I type > rails -v (I guess this is the right way?) > then I see > Rails 1.2.6 I believe you're doomed :-) Seriously, this has massive pain written all over it; 1.2.6 is ancient. If I were you, I'd find someone who knows Rails, let

Re: [Rails] There must be a more elegant way to do this

2011-06-03 Thread Tim Shaffer
I think the problem with doing that is that the arrays contain instances of models. Sounds like skt wants to consider an instance unique based on only two attributes of each instance. The best way might just to loop over the arrays and append them to a 4th array if the 4th array doesn't alread

Re: [Rails] There must be a more elegant way to do this

2011-06-03 Thread Michael Pavling
On 3 June 2011 17:49, skt wrote: > Now my task is to take all these records in different arrays and > extract out an array of unique records from them (unique combination > of user_id and address_id) as the same record may be present in > multiple arrays. (array1 + array2 + array3).uniq or [arr

Re: [Rails] Re: Creating common method in application ontroller

2011-06-03 Thread Michael Pavling
On 3 June 2011 18:34, Kevin wrote: > Out of curiosity what should one do if one wants to have a method inherited > by all models? You can monkey patch Object or Class if you really want... # patch in environment.rb class Object def your_method puts "my method is here" end end # console

Re: [Rails] Re: Creating common method in application ontroller

2011-06-03 Thread Kevin
Out of curiosity what should one do if one wants to have a method inherited by all models? Does rails already have a file for adding methods to the model base class? Or do we just ram our methods into ActiveModel and call it a day? I have run into almost the opposite scenario as the thread s

[Rails] Re: Stupid newbie question

2011-06-03 Thread Sta Canovist
On Jun 3, 6:54 pm, Hassan Schroeder wrote: > > You seem to be mixing up commands between Rails 2.x and 3.x. > Which do you have installed? Or more to the point, what is the app > you're trying to run based on? Well If I type rails -v (I guess this is the right way?) then I see Rails 1.2.6 -- Yo

[Rails] Re: Stupid newbie question

2011-06-03 Thread Sta Canovist
On Jun 3, 6:48 pm, Martin Wawrusch wrote: > It is ONE line copy and pasted into your shell and really the recommended > way to use Ruby on the Mac. It does not get much simpler than this. Ok IN that case I will give it a try. Thanks. -- You received this message because you are subscribed to

Re: [Rails] Re: Stupid newbie question

2011-06-03 Thread Hassan Schroeder
On Fri, Jun 3, 2011 at 9:21 AM, Sta Canovist wrote: > Passengers fails. I can install it, after installing macports. But > when I have to run the command for installing under apache then it > fails. I have tried to find answers but with no success. Well, you certainly won't get any answers witho

[Rails] There must be a more elegant way to do this

2011-06-03 Thread skt
Hello, I have a bunch of arrays containing records retrieved from the database in separate queries. That can't be changed - I have deal with the different arrays of these records. Each of these records contains, amongst other data fields, two ids - a user_id and an address_id. Now my task is to t

Re: [Rails] Re: Stupid newbie question

2011-06-03 Thread Martin Wawrusch
It is ONE line copy and pasted into your shell and really the recommended way to use Ruby on the Mac. It does not get much simpler than this. On Fri, Jun 3, 2011 at 9:44 AM, Sta Canovist wrote: > On Jun 3, 6:25 pm, Martin Wawrusch wrote: > > RVM to the rescue I guess: Go here: https://rvm.beg

[Rails] Re: Stupid newbie question

2011-06-03 Thread Sta Canovist
On Jun 3, 6:25 pm, Martin Wawrusch wrote: > RVM to the rescue I guess: Go here:  https://rvm.beginrescueend.com/ > install it, then go tohttp://rubygems.org/ and install rubygems (might > actually be installed with rvm, you need to check this). Isnt there an easier way? I have been installing und

[Rails] Re: How to safely escape raw sql with connection.select_all

2011-06-03 Thread Kevin
Thanks for the suggestion I will try it and report back. -- 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/rubyonrails-talk/-/YXZpYWczcnpPeHNK. To post to this group,

Re: [Rails] Re: Stupid newbie question

2011-06-03 Thread Martin Wawrusch
RVM to the rescue I guess: Go here: https://rvm.beginrescueend.com/ install it, then go to http://rubygems.org/ and install rubygems (might actually be installed with rvm, you need to check this). On Fri, Jun 3, 2011 at 9:21 AM, Sta Canovist wrote: > > > On Jun 2, 5:58 pm, Hassan Schroeder

[Rails] Re: Stupid newbie question

2011-06-03 Thread Sta Canovist
On Jun 2, 5:58 pm, Hassan Schroeder wrote: > Probably trivial to fix -- do you have all the XCode developer stuff on > your system(s)? In any case... Well, I guess it was not so trivial. In short: I have been trying to run either through passenger or webrick. Passengers fails. I can install it

[Rails] CKEditor + CarrierWave

2011-06-03 Thread Fernando Aureliano
someone already used the CarrierWave for do uploads with CKEditor? I'm looking for a tutorial or some information about how do it. Thanks! -- *Fernando Aureliano* -- [iOSDeveloper] - *ObjectiveC* [WebDesigner] - *CSS3&HTML5* *[WebDe

Re: [Rails] Re: ANN: PDFTron PDFNet SDK for RUBY

2011-06-03 Thread David Kahn
On Fri, Jun 3, 2011 at 9:43 AM, Walter Davis wrote: > > On Jun 3, 2011, at 9:58 AM, David Kahn wrote: > > >> >> On Fri, Jun 3, 2011 at 8:25 AM, paul h wrote: >> >> >> On Jun 3, 12:50 am, pdftrn wrote: >> > ANNOUNCING: >> > >> > PDFTron PDFNet SDK v.5.7. - A Ruby Extension module for all types o

[Rails] How to upgrade from Rails 3.0 to 3.1

2011-06-03 Thread Jatin
I have an application in Rails 3.0, which I want to upgrade to Rails 3.1. What should be the right approach to go for it? I have thought of this, and these are some of the things that come to my mind. I don't know which one to do first, and how to perform each step in its entirety. 1. Get all my j

Re: [Rails] Re: ANN: PDFTron PDFNet SDK for RUBY

2011-06-03 Thread Walter Davis
On Jun 3, 2011, at 9:58 AM, David Kahn wrote: On Fri, Jun 3, 2011 at 8:25 AM, paul h wrote: On Jun 3, 12:50 am, pdftrn wrote: > ANNOUNCING: > > PDFTron PDFNet SDK v.5.7. - A Ruby Extension module for all types of > PDF processing including rendering, conversion, editing, and creation.

[Rails] SomeClass is chainable by some_class, but how about Module::Class. How would I access that in the chain?

2011-06-03 Thread frizbe1605
I have something like BlogEngine::Blog.blog_engine_posts.new but it returns with BlogEnginePost instead of BlogEngine::Post. I'm new to using modules. Thanks, Steve -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group,

Re: [Rails] Re: ANN: PDFTron PDFNet SDK for RUBY

2011-06-03 Thread David Kahn
On Fri, Jun 3, 2011 at 8:25 AM, paul h wrote: > > > On Jun 3, 12:50 am, pdftrn wrote: > > ANNOUNCING: > > > > PDFTron PDFNet SDK v.5.7. - A Ruby Extension module for all types of > > PDF processing including rendering, conversion, editing, and creation. > > > > WHAT IT IS: > > > > PDFNet SDK is

[Rails] Re: ANN: PDFTron PDFNet SDK for RUBY

2011-06-03 Thread paul h
On Jun 3, 12:50 am, pdftrn wrote: > ANNOUNCING: > > PDFTron PDFNet SDK v.5.7. - A Ruby Extension module for all types of > PDF processing including rendering, conversion, editing, and creation. > > WHAT IT IS: > > PDFNet SDK is an amazingly comprehensive, high-quality PDF developer > toolkit for

[Rails] Using MongoHQ and central_logger on Heroku with rails app

2011-06-03 Thread satyamag
Hi I am trying to setup central_logger (https://github.com/customink/central_logger) to my heroku app. Can someone please point me to a tutorial or lay out steps on how I can achieve this? The readme is quite clear but doesn't say anything about heroku integration except for point 4 which says F

[Rails] Rack Middleware support for Rails 2.0.2? If not what is the alternative to implement similar functionality in Rails 2.0.2..

2011-06-03 Thread boddhisattva
Hello all, I am using Rails 2.0.2 and Ruby 1.8.7 and I need to make use of rack middleware for integrating an ajax file upload plugin(https:// github.com/valums/file-uploader) with paperclip in Rails( As given in this tutorial:- http://mooo.wordpress.com/2010/12/03/paperclip-valums%E2%80%9

Re: [Rails] assigning name from table 1 to table 2

2011-06-03 Thread Colin Law
On 2 June 2011 19:11, joanne wrote: > Hi all, > > I am new in Rials, I have problem to assign the first name from (model > - name1) to first-name (model name2) > > cuz when i create a name in table name1, i want it appears in table > name2 > > and my model relationship is: > > model name1  - ( has

[Rails] Re: assigning name from table 1 to table 2

2011-06-03 Thread Javix
First, I don't really understand the logic to do that. But, OK, it's up to you to define it. If you have the attribute 'first_name defined both in the two models, you should do something like this: model_name1 = Name1.create(:first_name=>'toto') model_name2 = Name2.new model_name2.first_name = mod

[Rails] can't run specs with foreign keys?

2011-06-03 Thread Mauro
I've set foreign key at database level. When I run rspec it says: permission denied: "RI_ConstraintTrigger_111473" is a system trigger: ALTER TABLE "categories" ENABLE TRIGGER ALL;ALTER TABLE "categories_suppliers" ENABLE TRIGGER ALL;ALTER TABLE "rusers" ENABLE TRIGGER ALL;ALTER TABLE "schema_migr

[Rails] valums ajax file upload + paperclip in Rails 2.x Options

2011-06-03 Thread mgj
Hello all, I am trying to setup ajax file upload + ajax display in Rails 2.0.2 for project specific purposes. I am using valums ajax file upload plugin(https://github.com/valums/file-uploader). Using this plugin, I have been able to upload these files working in my javascript and I am able to pass