Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

remove uniqueness validation for app #170

Closed
wants to merge 1 commit into from

3 participants

@bugaiov

The idea is that I'm using

class Project < ActiveRecord::Base
  has_many :rapns_apps, class_name: 'Rapns::App', dependent: :destroy
end

And I do want to have same name in a project scope.
Rails doesn't provide a neat way to skip validation or modifying them in an inherited class, lets say.
So maybe a good idea is to disable it. I mean, I don't see the advantages.

I'm open to discussion regarding this. Maybe this is only my opinion.

N

@mattconnolly

Couldn't this be served by a has_and_belongs_to relationship? In that case their would only be one instance of an "App" and projects could linked to it via a join table. And when the project is deleted, the join table entry could be removed.

This would also keep the relational integrity of notifications in the database.

Besides, having multiple apps would result in multiple connections from the rapns server, which may be an undesirable side affect of this.

@bugaiov

@mattconnolly Anyway an app will be created in the rapn_apps table where a unique validation of name is applied, hence I don't understand how I'll help.

@ileitch
Owner

Sorry, this can't and shouldn't be removed. As @mattconnolly pointed out, this will result in many open connections, which you probably do not want.

I suggest creating a join table between your projects and Rapns apps. You should only ever have a single Rapns apps for each app you actually have in iTunes connect.

@ileitch ileitch closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 26, 2013
  1. @bugaiov

    remove uniq validation

    bugaiov authored
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/rapns/app.rb
View
2  lib/rapns/app.rb
@@ -8,7 +8,7 @@ class App < ActiveRecord::Base
has_many :notifications, :class_name => 'Rapns::Notification', :dependent => :destroy
- validates :name, :presence => true, :uniqueness => { :scope => [:type, :environment] }
+ validates :name, :presence => true
validates_numericality_of :connections, :greater_than => 0, :only_integer => true
end
end
Something went wrong with that request. Please try again.