Ruby on Rails Saturday, October 31, 2015

Net::OpenTimeout in Devise::RegistrationsController#create

execution expired

Extracted source (around line #541):
539  540  541  542  543  544                
def tcp_socket(address, port)
TCPSocket.open address, port

--
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/64cd2335-913d-442c-90d1-65012e0bdbfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Sat, Oct 31, 2015 at 8:16 AM, Arto Lohi <arto.lohi@gmail.com> wrote:

> I got error message "You don't have write permissions for the
> /Library/Ruby/Gems/2.0.0 directory." when I tried install Rails to my Mac
> using command line command "gem install rails". I have admin rights on my
> machine.

If you're using the system Ruby, then you'll need to install gems with
`sudo`.

Most people use rvm or rbenv to avoid this (as well as enabling the
installation of multiple versions of Ruby and associated gems).

HTH,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
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/CACmC4yCSAYKiJ3U_46ByJL-jEAwVcWQNgDj6dhzHOdH33%3D8_8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi!

I got error message "You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory." when I tried install Rails to my Mac using command line command "gem install rails". I have admin rights on my machine. 

Can you help?

Arto

--
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/414b18c4-0f52-4b8c-8f45-1a7bd45bd4cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Friday, October 30, 2015

I have a problem with a form that either updates or creates depending on
whether the "project" exists already.

Im using the def create

def create
puts params.inspect
@project = current_user.projects.where(id:
params[:id]).first_or_create(project_params)
puts params.inspect
if @project.save
flash[:success] = "Project created!"
redirect_to root_url
else
flash[:success] = "Project not created!"
redirect_to root_url
end
end

Problem is it never finds the existing record.

generated SQL is


SELECT "projects".* FROM "projects" WHERE "projects"."user_id" = ? AND
"projects"."id" IS NULL ORDER BY "projects"."created_at" DESC LIMIT 1
[["user_id", 1]]
Im sending the parameters in wrong but i'm not sure of the solution.

--
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 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/566af89afa123c972dce3df6d89de911%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi everyone,

I am happy to announce that Rails 4.2.5.rc1 and 4.1.14.rc1 have been released.

If no regressions are found expect the final release this Wednesday, on November 4, 2015.
If you find one, please open an [issue on GitHub](https://github.com/rails/rails/issues/new)
and mention me (@rafaelfranca) on it, so that we can fix it before the final release.

## CHANGES since 4.1.13

To view the changes for each gem, please read the changelogs on GitHub:


*Full listing*

To see the full list of changes, [check out all the commits on

## CHANGES since 4.2.4

To view the changes for each gem, please read the changelogs on GitHub:


*Full listing*

To see the full list of changes, [check out all the commits on

## SHA-1

If you'd like to verify that your gem is the same as the one I've uploaded,
please use these SHA-1 hashes.

Here are the checksums for 4.1.14.rc1:

```
$ shasum *4.1.14.rc1*
6c4513c4f2a57d11fe8e9abafacde175a284a0fc  actionmailer-4.1.14.rc1.gem
27eeb9c788be0323eb459edda2b4d09418f37c40  actionpack-4.1.14.rc1.gem
2f70d52109b8be2c2dfbc57992fb1070a3a49fc5  actionview-4.1.14.rc1.gem
d3aafc6b61999fa0c9a363dfc626c93df9e460a2  activemodel-4.1.14.rc1.gem
55ea63bcca5925652956d194e8dbf4aca1780888  activerecord-4.1.14.rc1.gem
f771aa7d47c8a390449f577024d9335f7487294e  activesupport-4.1.14.rc1.gem
b3a16b8372ec44927196d38a12cc72fc97ad54c8  rails-4.1.14.rc1.gem
f1be582957f2494e13462f464e28afbaf938d233  railties-4.1.14.rc1.gem
```

Here are the checksums for 4.2.5.rc1:

```
$ shasum *4.2.5.rc1*
95125668842661dda2db412a45226f9b1219b522  actionmailer-4.2.5.rc1.gem
d9c6b7e38f9eab5975ca2549cb88b6700a0acdfd  actionpack-4.2.5.rc1.gem
f40ad9c7a5cd2c4b14f96615fdf5627d4fcaa9f3  actionview-4.2.5.rc1.gem
edcc197c162d64d663cf1049851105777c9a41ff  activejob-4.2.5.rc1.gem
eff7203c26da06c76a667428c70dc8741afac67e  activemodel-4.2.5.rc1.gem
c719ffeaffbd0f3bc1e23ed1db32df84662c0460  activerecord-4.2.5.rc1.gem
311d02a075d1669eba52b026ac60b834e02e96c6  activesupport-4.2.5.rc1.gem
810f02ff2930062f269340bc7df4e4e213a168a3  rails-4.2.5.rc1.gem
e7f842b19b4e3f67625d3df3127ed99392f19bed  railties-4.2.5.rc1.gem
```

I'd like to thank you all, every contributor who helped with this release.

--
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/CAC9YFzce%3Du1eVvh%2Bcq5y13BfzvQX0TNPbXhi5eeM-R98cQ8gXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi,

I am trying to create a design for user defined tables which could be stored in a database then initialized from a controller as needed. At present I am having a bit of trouble getting these metamodels into the rails env from a controller. Is there a way that I can class_eval a model that would be able to be seen for the duration of that process?

class Admin::UdtManagersController < Admin::Auth #< ApplicationController
  before_filter :initialize_meta_environment

  def index # rails complains if this isn't here
  end

    private

      def initialize_meta_environment
        @table = 'review_processes' #define this hard coded for now... later passed via param
        @model = @table.classify

        init_models
  

      end

      def init_models
        class_eval= %q{
           class #{@model} < ActiveRecord::Base

           validates_presence_of :summary_reviews
           end
          }

       ## How can I eval this model so it will become part of my application for that process?
 
      end
end

Any help is totally appreciated! Thanks in advance.

-Mark

--
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/d78fcd66-0caa-4414-b2ca-f01b4a333588%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

why dont you just do this....


class Artist < ActiveRecord::Base
has_many :events, dependent: :destroy
end

class Event < ActiveRecord::Base
belongs_to :artist
end

a = Artist.first
a.events which will return a list of events connected to that artist

e = Event.first
e.artist which will return the artist that is connected to that event.

Maybe explain what your user story is to better understand. With what
you posted I comprehended the statement above.

--
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 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/8be9ad7fa3b35df3628035d98ecf187b%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Thanks Colin

On Thursday, October 29, 2015 at 12:54:33 PM UTC-4, fugee ohu wrote:

I put a .gemrc file in my home directory, the same directory my Gemfile is in, with just "gem: --no-ri --no-rdoc" but when i install gems the docs still get installed, causing me to have to wait

--
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/0129bdeb-2a3f-408e-b3d9-2857bc91f452%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Thursday, October 29, 2015

Hello All, 

As the Corporate Recruiter with IT Glue, I welcome interested, experienced development professionals to consider an opportunity with a very well-funded start up in Vancouver, BC. 

Details regarding the opportunity are illustrated via our Careers page. This is a full-time, permanent role with a team poised for growth within an organization ramping up aggressively but conscientiously. 

I'm highly impressed with our founder, Chris Day; check out the profile of this 2013 Top 40-under-40 recipient. We're a flat organization attracting the right type of people: those with a sense of urgency balanced with humanity. That is, work is not to be robotic or create robots out of us. Being responsible for HR and Recruitment, I'm committed to revolutionizing recruitment; this means, my mandate is to attract and retain top-talent where they want to be. 

Please review the role and apply directly onsite. If you have any questions, feel free to connect with me via LinkedIn as well. There's more to a role than money alone but, damn, what we're offering is awesome!

Regards, 
Semira

--
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/842e6406-d873-46c2-a0ce-64b268a59a56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Vale ya me contesto yo, y lo publico por si a alguien le sirve:

alias_attribute :new_name, :old_name

;D

--
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 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/dc51ae5c6559eebb9418a0a2bf0c96da%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Buenas.
Tenía una base de datos ya existente, por lo que no he tenido que
realizar migraciones.
Para decirle que tablas usa mi modelo he usado:
self.table_name = 'nombre_tabla_db'
¿Habría algo igual para hacerlo en las columnas?, he estado mirando y
no encuentro nada, todo sale con rails g migration.. y yo no quiero
realizar migraciones.

Un saludo y gracias por la ayuda.

--
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 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/f5376e96a631c3faa5e37789bf92927b%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 29 October 2015 at 16:54, fugee ohu <fugee279@gmail.com> wrote:
> I put a .gemrc file in my home directory, the same directory my Gemfile is
> in, with just "gem: --no-ri --no-rdoc" but when i install gems the docs
> still get installed, causing me to have to wait

Gemfile should in the root directory of the rails application, not in
the users home directory, which is where .gemrc should be (at least
that is where mine is). So on Ubuntu linux it is
/home/username/.gemrc

Colin

--
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/CAL%3D0gLtSZX-6dhV-5WHy709E6Qta43gqbPr1xW%2BG01w0FpGsOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I put a .gemrc file in my home directory, the same directory my Gemfile is in, with just "gem: --no-ri --no-rdoc" but when i install gems the docs still get installed, causing me to have to wait

--
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/7296f43c-910b-455a-9584-ce1fd6b500f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I have a situation where I am developing a Railtie Engine and have two dummy apps for testing, and therefore two distinct 'rails_helper.rb' helpers to load one or the other app per specific spec file.

# rails_helper_1.rb
...
require File.expand_path("dummy_1/config/environment", File.dirname(__FILE__))
...


# rails_helper_2.rb
...
require File.expand_path("dummy_2/config/environment", File.dirname(__FILE__))
...



Then specs like:


# spec/controllers/dummy_1/some_controller_spec.rb
require 'rails_helper_1.rb'
...


# spec/controllers/dummy_2/some_controller_spec.rb
require 'rails_helper_2.rb'
...



The problem is that, once the environment from dummy_1 is loaded and RSpec tries to load the environment from dummy_1, it throws the error: 'initialize!': Application has been already initialized. (RuntimeError)

I cannot find the way to "unload" or "uninitialize" a currently loaded app env from RSpec, any ideas?

--
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/e789c06c-3131-4b06-b816-a554f8511af8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Thursday, October 29, 2015 at 6:59:09 AM UTC, Eduardo Campestrini wrote:
    def reject_contact(attributes)
      attributes['phone'].blank?
      attributes['website'].blank?
    end


This doesn't do what you want - it's return value depends solely on the blankness of the website attribute. 

Fred

--
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/91b49968-27cb-4de6-b8d0-8741530715b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

 Can you try below solution:

private
    def reject_contact(attributes)
      attributes['phone'].blank? || attributes['website'].blank?
    end

    def reject_job(attributes)
      attributes['company'].blank? || attributes['title'].blank?
    end



On Thursday, October 29, 2015 at 12:29:09 PM UTC+5:30, Eduardo Campestrini wrote:
Hi!

My reject_if filter is not working:

2.2.3 :002 > params = { lead: {name: 'Eduardo', lastName: 'Campestrini', job_attributes: { company: 'RD' } } }
 => {:lead=>{:name=>"Eduardo", :lastName=>"Campestrini", :job_attributes=>{:company=>"RD"}}} 
2.2.3 :003 > lead = Lead.create(params[:lead])
   (0.1ms)  begin transaction
  SQL (1.7ms)  INSERT INTO "leads" ("name", "lastName", "created_at", "updated_at") VALUES (?, ?, ?, ?)  [["name", "Eduardo"], ["lastName", "Campestrini"], ["created_at", "2015-10-29 03:35:49.845738"], ["updated_at", "2015-10-29 03:35:49.845738"]]
   (1.2ms)  commit transaction
 => #<Lead id: 11, name: "Eduardo", lastName: "Campestrini", created_at: "2015-10-29 03:35:49", updated_at: "2015-10-29 03:35:49"> 
2.2.3 :004 > 


class Lead < ActiveRecord::Base
  has_one :contact, dependent: :destroy
  has_one :job, dependent: :destroy

  accepts_nested_attributes_for :contact, reject_if: :reject_contact
  accepts_nested_attributes_for :job, reject_if: :reject_job

  validates :name, presence: true, length: { maximum: 50 }
  validates :lastName, presence: true, length: { maximum: 100 }

  private
    def reject_contact(attributes)
      attributes['phone'].blank?
      attributes['website'].blank?
    end

    def reject_job(attributes)
      attributes['company'].blank?
      attributes['title'].blank?
    end
end

class Job < ActiveRecord::Base
  belongs_to :lead
  validates :company, presence: true, length: { maximum: 20 }
  validates :title, presence: true, length: { maximum: 50 }
end


class Contact < ActiveRecord::Base
  belongs_to :lead
  validates :phone, presence: true, length: { maximum: 20 }
  validates :website, presence: true, length: { maximum: 50 }
end

Thank,
Eduardo

--
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/d66dad11-9b1c-44d0-a472-c1d6b186091d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails


On 29 Oct 2015 06:58, "Eduardo Campestrini" <macabrus@gmail.com> wrote:
>
> Hi!
>
> My reject_if filter is not working:
>
> 2.2.3 :002 > params = { lead: {name: 'Eduardo', lastName: 'Campestrini', job_attributes: { company: 'RD' } } }
>  => {:lead=>{:name=>"Eduardo", :lastName=>"Campestrini", :job_attributes=>{:company=>"RD"}}} 
> 2.2.3 :003 > lead = Lead.create(params[:lead])
>    (0.1ms)  begin transaction
>   SQL (1.7ms)  INSERT INTO "leads" ("name", "lastName", "created_at", "updated_at") VALUES (?, ?, ?, ?)  [["name", "Eduardo"], ["lastName", "Campestrini"], ["created_at", "2015-10-29 03:35:49.845738"], ["updated_at", "2015-10-29 03:35:49.845738"]]
>    (1.2ms)  commit transaction
>  => #<Lead id: 11, name: "Eduardo", lastName: "Campestrini", created_at: "2015-10-29 03:35:49", updated_at: "2015-10-29 03:35:49"> 
> 2.2.3 :004 > 
>
>
> class Lead < ActiveRecord::Base
>   has_one :contact, dependent: :destroy
>   has_one :job, dependent: :destroy
>
>   accepts_nested_attributes_for :contact, reject_if: :reject_contact
>   accepts_nested_attributes_for :job, reject_if: :reject_job
>
>   validates :name, presence: true, length: { maximum: 50 }
>   validates :lastName, presence: true, length: { maximum: 100 }
>
>   private
>     def reject_contact(attributes)
>       attributes['phone'].blank?
>       attributes['website'].blank?
>     end
>
>     def reject_job(attributes)
>       attributes['company'].blank?
>       attributes['title'].blank?
>     end
> end
>
> class Job < ActiveRecord::Base
>   belongs_to :lead
>   validates :company, presence: true, length: { maximum: 20 }
>   validates :title, presence: true, length: { maximum: 50 }
> end
>
>
> class Contact < ActiveRecord::Base
>   belongs_to :lead
>   validates :phone, presence: true, length: { maximum: 20 }
>   validates :website, presence: true, length: { maximum: 50 }
> end

Have you debugged into the code to see what is going wrong? In particular is your filter method being called and if so what is the result?

Colin

--
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/CAL%3D0gLvZMVCfN0anQVc6Jrr_5FSL%2BumxO9SuJ76RZwhj8V%3Ds5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Wednesday, October 28, 2015



On Wed, Oct 28, 2015 at 3:45 PM, Rodrigo Lueneberg <lists@ruby-forum.com> wrote:
How can I refactor this coordinate validation routine so that I can use
this method with other fields of the same type, for instance, with
"full_last_position" and also maintain the cleanliness of the code and
avoiding repeating method code?

Maybe what you're looking for is ActiveModel::Validator ?

 

class Provider < ActiveRecord::Base
  include UtilsModule
  attr_accessor :full_target_area_coordinate, :full_last_position # this
field validates and saves coordinate

  validate :full_target_area_coordinate, :is_valid_coordinate?

  def is_valid_coordinate?  # searches local geo_codes table for valid
zip
    coord = self.full_target_area_coordinate.to_str
    match = coord.match(/^(-?\d{1,2}\.\d{6}),\s*(-?\d{1,2}\.\d{6})$/)
    if match.nil?  # invalid format
      errors.add(:target_area_coordinate, :invalid)
      return false
    end

    self.target_area_coordinate =
UtilsModule.convert_coordinate(self.full_target_area_coordinate)
    return true
  end

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 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/b1d068a6f9732cbadddf00e3a4bc1295%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAHUC_t8nbNXyzeyPzsVZjYFc7_h5OOPXTLn6sgWTLhMunGS27Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Thu, Oct 29, 2015 at 4:45 AM, Rodrigo Lueneberg <lists@ruby-forum.com> wrote:
> def is_valid_coordinate? # searches local geo_codes table for valid
> zip
> coord = self.full_target_area_coordinate.to_str

coord = self.to_str

> match = coord.match(/^(-?\d{1,2}\.\d{6}),\s*(-?\d{1,2}\.\d{6})$/)
> if match.nil? # invalid format
> errors.add(:target_area_coordinate, :invalid)

errors.add(self.to_sym, :invalid)


> return false
> end
>
> self.target_area_coordinate =
> UtilsModule.convert_coordinate(self.full_target_area_coordinate)

just return true here.
i would suggest separating the conversion from the validation.

kind regards,
--botp

> return true
> 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/CAAwHHQiQp3TF9kEb4kGU%3DfnLWN3%3DNnieR-Wuif1%3D%2B6cmnXr1aQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi!

My reject_if filter is not working:

2.2.3 :002 > params = { lead: {name: 'Eduardo', lastName: 'Campestrini', job_attributes: { company: 'RD' } } }
 => {:lead=>{:name=>"Eduardo", :lastName=>"Campestrini", :job_attributes=>{:company=>"RD"}}} 
2.2.3 :003 > lead = Lead.create(params[:lead])
   (0.1ms)  begin transaction
  SQL (1.7ms)  INSERT INTO "leads" ("name", "lastName", "created_at", "updated_at") VALUES (?, ?, ?, ?)  [["name", "Eduardo"], ["lastName", "Campestrini"], ["created_at", "2015-10-29 03:35:49.845738"], ["updated_at", "2015-10-29 03:35:49.845738"]]
   (1.2ms)  commit transaction
 => #<Lead id: 11, name: "Eduardo", lastName: "Campestrini", created_at: "2015-10-29 03:35:49", updated_at: "2015-10-29 03:35:49"> 
2.2.3 :004 > 


class Lead < ActiveRecord::Base
  has_one :contact, dependent: :destroy
  has_one :job, dependent: :destroy

  accepts_nested_attributes_for :contact, reject_if: :reject_contact
  accepts_nested_attributes_for :job, reject_if: :reject_job

  validates :name, presence: true, length: { maximum: 50 }
  validates :lastName, presence: true, length: { maximum: 100 }

  private
    def reject_contact(attributes)
      attributes['phone'].blank?
      attributes['website'].blank?
    end

    def reject_job(attributes)
      attributes['company'].blank?
      attributes['title'].blank?
    end
end

class Job < ActiveRecord::Base
  belongs_to :lead
  validates :company, presence: true, length: { maximum: 20 }
  validates :title, presence: true, length: { maximum: 50 }
end


class Contact < ActiveRecord::Base
  belongs_to :lead
  validates :phone, presence: true, length: { maximum: 20 }
  validates :website, presence: true, length: { maximum: 50 }
end

Thank,
Eduardo

--
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/8abb9c78-981c-45d7-84ca-5e49948fb946%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

How can I refactor this coordinate validation routine so that I can use
this method with other fields of the same type, for instance, with
"full_last_position" and also maintain the cleanliness of the code and
avoiding repeating method code?

class Provider < ActiveRecord::Base
include UtilsModule
attr_accessor :full_target_area_coordinate, :full_last_position # this
field validates and saves coordinate

validate :full_target_area_coordinate, :is_valid_coordinate?

def is_valid_coordinate? # searches local geo_codes table for valid
zip
coord = self.full_target_area_coordinate.to_str
match = coord.match(/^(-?\d{1,2}\.\d{6}),\s*(-?\d{1,2}\.\d{6})$/)
if match.nil? # invalid format
errors.add(:target_area_coordinate, :invalid)
return false
end

self.target_area_coordinate =
UtilsModule.convert_coordinate(self.full_target_area_coordinate)
return true
end

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 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/b1d068a6f9732cbadddf00e3a4bc1295%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hello Friends,

Again new updates are available
https://github.com/igorkasyanchuk/rails_db

0.6 - October 28, 2015

- better results if no results
- add truncate table
- add information about indexes
- fixed issue with helpers (thanks @losadaem)
- added delete for records (by PK)
- added information about primary key

0.5.1 - October 27, 2015

- removed log files and other garbage to reduce size of gem

0.5 - October 26, 2015

- added config.verify_access_proc to make possible enable access for
users (for example current_user.admin?)
- small tweaks to rails_db_data_table and rails_db_data_sql
- other minor fixes
- working on documentation

--
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 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/b6e69b46e3ed5403bb99f1f72cc59e2e%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I need to make realtime updates for all subscribers. After creating new record i need to publish it for all subscribers. 
I found a solution using postgre listen/notify
In controller: 
def index
  response
.headers['Content-Type'] = 'text/event-stream'
  sse
= SSE.new(response.stream)
 
begin
   
Comment.on_change do |data|
      sse
.write(data)
   
end
 
rescue IOError
   
# Client Disconnected
  ensure
    sse
.close
 
end
  render nothing
: true
end

and model
[...]
after_create
:notify_comment_added
[...]
private

def notify_comment_added
 
Comment.connection.execute "NOTIFY comments, 'data'"
end


class << self
 
def on_change
   
Comment.connection.execute "LISTEN comments"
    loop
do
     
Comment.connection.raw_connection.wait_for_notify do |event, pid, comment|
       
yield comment
     
end
   
end
 
ensure
   
Comment.connection.execute "UNLISTEN comments"
 
end
end


Problems are
1) Every listeners occupies a connection to db, and after some clients its reach maximum and i got ActiveRecord timeout
2) it works only with config.cache_classes = true and config.eager_load = true  otherwise servers froze on 1-2nd execution of controller. And its a big pain to restart server after every small change.

Does rails have any another solutions to perform this task? 




--
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/0ec03c37-a117-4845-ad10-d02434669043%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 28 October 2015 at 11:00, Shruthi Ss <lists@ruby-forum.com> wrote:
> While creating CR/NF,Target Version must be auto-filled with a
> particular target version(Ex:Sprint 1) and It must also be read only.How
> can I do this requirement Please suggest me

Google has failed me in my attempts to determine what this message is
about. What is CR/NF?

Colin

--
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/CAL%3D0gLtqMkHCn%2B5XA35sU0E346eVZTBfZyXR5rThoDpmWsBWNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

While creating CR/NF,Target Version must be auto-filled with a
particular target version(Ex:Sprint 1) and It must also be read only.How
can I do this requirement Please suggest me

--
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 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/37ff2a938483ab7453a657a659a9dd10%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

thanks. I fixed it. Sure I will consider your suggestion.

On Wed, Oct 28, 2015 at 1:50 PM, Colin Law <clanlaw@gmail.com> wrote:
On 28 October 2015 at 07:00, honey ruby <emailtohoneyruby@gmail.com> wrote:
> Hi all,
>
> In a table there is column called village which is text datatype. Now my
> question is few records will have 1,2 under village column some records will
> have only 2 or 1. when I do query I should be able to select those records
> which has 1,2 . If I want to select all the records of village(2). How can I
> do this in rails query.
>
> Tried with Like and IN (?) in query but did not work
>
> City.find(:all, :conditions => ["village LIKE ?",2])
> City.find(:all, :conditions => ["village IN (?)",2])
>  as it is text datatype and if I pass 1,2 I am able to get the records but
> while passing single value like 1 or 2
>
> Kindly suggest how to get it

Don't store the data like that, it will cause you endless problems and
you will look back in the future and ask why you did it that way.
Possibly it should be in separate fields, or even in a separate table.
It depends what the data represents.  If you provide the context then
it may be possible to suggest the best alternative.

Colin

--
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/CAL%3D0gLvzeWMA7nVB1WW9ZAE%2BW15JTuFpEjdko125DpL0h4BVGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAOKUzC%3DOK1P%3D%2BzSJeS7fO7eH-UzGmrQrUnM7oggDcSK4AMKAuw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 28 October 2015 at 07:00, honey ruby <emailtohoneyruby@gmail.com> wrote:
> Hi all,
>
> In a table there is column called village which is text datatype. Now my
> question is few records will have 1,2 under village column some records will
> have only 2 or 1. when I do query I should be able to select those records
> which has 1,2 . If I want to select all the records of village(2). How can I
> do this in rails query.
>
> Tried with Like and IN (?) in query but did not work
>
> City.find(:all, :conditions => ["village LIKE ?",2])
> City.find(:all, :conditions => ["village IN (?)",2])
> as it is text datatype and if I pass 1,2 I am able to get the records but
> while passing single value like 1 or 2
>
> Kindly suggest how to get it

Don't store the data like that, it will cause you endless problems and
you will look back in the future and ask why you did it that way.
Possibly it should be in separate fields, or even in a separate table.
It depends what the data represents. If you provide the context then
it may be possible to suggest the best alternative.

Colin

--
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/CAL%3D0gLvzeWMA7nVB1WW9ZAE%2BW15JTuFpEjdko125DpL0h4BVGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi all,

In a table there is column called village which is text datatype. Now my question is few records will have 1,2 under village column some records will have only 2 or 1. when I do query I should be able to select those records which has 1,2 . If I want to select all the records of village(2). How can I do this in rails query.

Tried with Like and IN (?) in query but did not work

City.find(:all, :conditions => ["village LIKE ?",2])
City.find(:all, :conditions => ["village IN (?)",2])
 as it is text datatype and if I pass 1,2 I am able to get the records but while passing single value like 1 or 2

Kindly suggest how to get it


Thanks in advance

--
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/7f4c9d50-1d6b-4f37-8aa3-2af03cf82478%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Tuesday, October 27, 2015

thank you. Let me check.

On Tue, Oct 27, 2015 at 2:14 PM, Colin Law <clanlaw@gmail.com> wrote:
On 27 October 2015 at 06:37, honey ruby <emailtohoneyruby@gmail.com> wrote:
> Hi all,
>
> I have to show data in csv in one cell but in new line.
> eg:   2015    xyz
>         2014   abc
>
> How can I show this way using csv in rails. am using faster csv.

It depends what you want to do with the csv.  It may be that
generating something like
"a","b","2015 xyz
2014 abc","c"
might work, but it will depend on whether the s/w you are feeding the
csv into will accept that format.

You can experiment by generating some files by hand to see if it is ok.

Colin

--
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/CAL%3D0gLv9CrR_uQ6reRS%2BskLWLLcHMLadP%2BCon14ekuRJbvnpaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAOKUzCmjFnDqS1N6DSwS565bG5d3BaFRJSBXA0OdNKuJLDuLgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Mon, Oct 26, 2015 at 9:28 PM, Srinivas Kalyan <kalyan.nandivada@gmail.com> wrote:
Hi All,

I am new Ruby on Rails, I had installed as described below on my machine. Could you please advise good editor compatible to the below configuration?

There are several good coding editors to choose from:

* Sublime Text 2 or 3
* Atom
* Brackets

Most people don't recommend RubyMine as it can be costly, and many people do not think using an IDE helps one learn enough, however I find it useful enough even if it isn't my main editor, which is emacs.

I have a hard time recommending Vim and Emacs to new developers, even though they are both really great editors. The problem being, perhaps, as editors they both can have their own learning curve piled on top of learning the framework.

 
And any additional steps required once i install these?
  1. MySQL 5.6.27
  2. Ruby 2.2
  3. Git 
  4. Rails 4.0
Appreciate your help! Thank you.

--
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/f8892454-8444-4db2-b9bf-2269ee3bc61c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAHUC_t-PBVfS2iHJ7vcdmn-rnYFssdNzBoiR_eqQ3w2N-7YcJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 27 October 2015 at 02:28, Srinivas Kalyan <kalyan.nandivada@gmail.com> wrote:
> Hi All,
>
> I am new Ruby on Rails, I had installed as described below on my machine.
> Could you please advise good editor compatible to the below configuration?
> And any additional steps required once i install these?
>
> MySQL 5.6.27
> Ruby 2.2
> Git
> Rails 4.0

You have not told us which operating system you are using. Assuming
it is a linux or Mac OS then I recommend installing using rvm (others
prefer rbenv).

However I suggest that you start by working right through a good
tutorial such as railstutorial.org (which is free to use online).
This tutorial runs in the cloud and does not need you to install
anything to get going. Once you have learnt the basics then
installing on your own machine will be easier as you will know what to
expect.

As a matter of interest why have you installed an almost obsolete
version of Rails? 4.2.4 is the current version.

Colin

--
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/CAL%3D0gLsPss%2BakzPwv6R5m2fMthhAYBR7PJRjKDxaPGJhxEDMoA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.