-
Notifications
You must be signed in to change notification settings - Fork 69
Organizations: minor code cleanup #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,7 @@ class Organization < ActiveRecord::Base | |
has_many :members, dependent: :destroy | ||
has_many :users, -> { order "members.created_at DESC" }, through: :members | ||
has_many :all_accounts, class_name: "Account", inverse_of: :organization | ||
has_many :all_movements, class_name: "Movement", through: :all_accounts, source: :movements do | ||
def with_transfer | ||
joins(transfer: :movements) | ||
end | ||
end | ||
has_many :all_movements, class_name: "Movement", through: :all_accounts, source: :movements | ||
has_many :all_transfers, class_name: "Transfer", through: :all_movements, source: :transfer | ||
has_one :account, as: :accountable | ||
has_many :member_accounts, through: :members, source: :account | ||
|
@@ -15,11 +11,7 @@ def with_transfer | |
has_many :inquiries | ||
has_many :documents, as: :documentable | ||
|
||
scope :matching, ->(str) { | ||
where(Organization.arel_table[:name].matches("%#{str}%")) | ||
} | ||
|
||
validates :name, uniqueness: true | ||
validates :name, presence: true, uniqueness: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's make sure we also have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree @sauloperez I'll review the schema and in case this is missing, I'll create a migration to fix that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @markets can you please check this, thanks!!! (no rush of course 😄 ) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see you did it already here b9d9b96 right? |
||
|
||
before_validation :ensure_url | ||
after_create :create_account | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class ChangeOrganizationsNameConstraints < ActiveRecord::Migration | ||
def up | ||
change_column_null :organizations, :name, false | ||
add_index :organizations, :name, unique: true | ||
end | ||
|
||
def down | ||
change_column_null :organizations, :name, true | ||
remove_index :organizations, :name | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we removing the
q
param? That will break the search, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted it becasue I can't found any point of the app using this search.