Skip to content

Commit

Permalink
add support for redmine3 and RoR4
Browse files Browse the repository at this point in the history
  • Loading branch information
tofi86 committed Jun 2, 2015
1 parent 91e8f91 commit 5c2b922
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/controllers/project_aliases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ def index
'identifier' => "#{Project.table_name}.identifier",
'project' => "#{Project.table_name}.name"
)
@projects = Project.visible.find(:all)
@aliases = ProjectAlias.find(:all, :include => :project, :order => sort_clause)
@projects = Project.visible.all
@aliases = ProjectAlias.includes(:project).order(sort_clause).all
render(:layout => !request.xhr?)
end

def new
@alias = ProjectAlias.new
@projects = Project.visible.find(:all, :order => 'lft')
@projects = Project.visible.order(:lft => :desc).all
end

def create
Expand All @@ -29,7 +29,7 @@ def create
flash[:notice] = l(:notice_successful_create)
redirect_to(:action => 'index')
else
@projects = Project.find(:all, :order => 'lft')
@projects = Project.order(:lft => :desc).all
render('project_aliases/new')
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/models/project_alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ProjectAlias < ActiveRecord::Base
validates_format_of :alias, :with => IDENTIFIER_RE
validates_exclusion_of :alias, :in => %w(new)

attr_accessible :alias, :project_id

def validate
if self.alias == self.project.identifier
errors.add(:alias, :same_as_identifier)
Expand Down
2 changes: 1 addition & 1 deletion lib/alias_project_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def find_by_identifier(*args)
project_alias = ProjectAlias.find_by_alias(args.first)
return project_alias.project if project_alias
end
find_all_by_identifier(*args).first
find_by(:identifier => args.first)
end

end
Expand Down

0 comments on commit 5c2b922

Please sign in to comment.