Ruby on Rails Monday, February 2, 2015

My guess would be that something is getting loaded twice.  I suggest
taking out all the requires and putting them back till you get the
problem.  That may help you to home in on it.

Yes, it seems some constant is already initialized.

I tried removing the includes, but they are all needed... 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3932bc6b-f8b0-4f7a-9f4f-4bb110eff41c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Sunday, February 1, 2015

hello guys,

i am trying to deploy my application on heroku but when i type gem install something wrong happens as you can see in the image attached in this topic. some of you can help me to find a way to fix this? thanks :)

i am using Linux Ubuntu 14
i already installed libpq


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2f9cd279-b47f-4f6d-8d6c-370db75ed5f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Dear everyone,

I'd like to ask two questions, how can I optimize my performance of my current model?

I'd like to use the information from translations table as it is (all columns) ....

 => Translation(id: integer, word_id: integer, conversion_id: integer, created_at: datetime, updated_at: datetime, user_id: string, unit_id: integer, last_learned: date, missed: integer, learned: integer) 

... and merge it to any translations/conversions children of Word.

My model getter self_with_translations should attach it to all translations/conversions but using join.

Second thing would be to optimize the check for in unit_ids section for only select unit_ids once and not have many selects.

The program is right here: http://open-voc.org

I appreciate any help,

kind regards, 
Alex

Code below:
class Word < ActiveRecord::Base

  has_and_belongs_to_many :conversions, class_name: "Word",
                          join_table: "translations",
                          association_foreign_key: "conversion_id"

  def available_units=(unit_ids_as_array)
    @available_units = unit_ids_as_array
  end

  def available_units
    @available_units || []
  end

  def with_enriched_data
    #@FIXME join merge instead of calling sep.
    meta = Translation.where(word_id: self.id).first
    # fix for deleted units, don't deliver them!
    self.available_units = Unit.all.map{|u| u.id } # @FIXME Cache or call only one time
    unit_id = meta.unit_id if self.available_units.include? meta.unit_id
    # enrich with attrs unit_id, ..........
    attributes.merge(unit_id:  unit_id, missed: meta.missed)
  end

  def self_with_translations(targetlang_id={})
    conversions = self.conversions.where(language_id: targetlang_id).map do |c|
      c.with_enriched_data
    end
    attributes.merge(translations: conversions)
  end

end

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4ecdc95d-e483-4589-8656-44254be5b0a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.