Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/helpers/upmin/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module ApplicationHelper
def body_classes
ret = []

controller = "c-#{params[:controller].gsub(/_/, "-").gsub("upmin/", "")}"
controller = "c-#{params[:controller].tr("_", "-").tr("upmin/", "")}"
ret << controller

action = "a-#{params[:action].gsub(/_/, "-")}"
action = "a-#{params[:action].tr("_", "-")}"
ret << action

if params[:klass]
Expand All @@ -19,7 +19,7 @@ def body_classes

def body_data
ret = {}
ret[:controller] = params[:controller].camelize.gsub("Upmin::", "")
ret[:controller] = params[:controller].camelize.tr("Upmin::", "")
ret[:action] = params[:action].camelize
return ret
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
-# TODO(jon): Break these into partials possibly?
- if type == :string
.form-group
= label(:q, "#{attr_name}_cont", attr_name.to_s.capitalize.gsub("_", " "))
= label(:q, "#{attr_name}_cont", attr_name.to_s.capitalize.tr("_", " "))
= text_field(:q, "#{attr_name}_cont", class: "form-control")

- if type == :integer
.form-group
= label(:q, "#{attr_name}_cont", attr_name.to_s.capitalize.gsub("_", " "))
= label(:q, "#{attr_name}_cont", attr_name.to_s.capitalize.tr("_", " "))
.input-group
.input-group-addon From
= number_field(:q, "#{attr_name}_gteq", class: "form-control")
Expand All @@ -25,7 +25,7 @@
- if type == :datetime && Rails::VERSION::MAJOR == 4
-# TODO(jon): Add date fields to search boxes for Rails 3
.form-group
= label(:q, "#{attr_name}_cont", attr_name.to_s.capitalize.gsub("_", " "))
= label(:q, "#{attr_name}_cont", attr_name.to_s.capitalize.tr("_", " "))
%br
From
= date_field(:q, "#{attr_name}_gteq", class: "form-control")
Expand Down
2 changes: 1 addition & 1 deletion lib/upmin/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def errors?
end

def label_name
return name.to_s.gsub(/_/, " ").capitalize
return name.to_s.tr("_", " ").capitalize
end

def form_id
Expand Down
4 changes: 2 additions & 2 deletions lib/upmin/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def Model.find_class(model)
def Model.find_or_create_class(model_name)
::Rails.application.eager_load!

create_name = model_name.gsub(":", "")
create_name = model_name.tr(":", "")
return "Admin#{create_name}".constantize
rescue NameError
if model_name.match(/::/)
Expand Down Expand Up @@ -170,7 +170,7 @@ def Model.model_name
end

def Model.humanized_name(type = :plural)
names = model_class_name.split(/(?=[A-Z])/).map{|n| n.gsub(":", "")}
names = model_class_name.split(/(?=[A-Z])/).map{|n| n.tr(":", "")}
if type == :plural
names[names.length-1] = names.last.pluralize
end
Expand Down
2 changes: 1 addition & 1 deletion lib/upmin/parameter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def title
end

def label_name
name.to_s.capitalize.gsub("_", " ")
name.to_s.capitalize.tr("_", " ")
end

def type
Expand Down