Skip to content
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

Camerontaylor rails5 #199

Open
wants to merge 6 commits into
base: rails5
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion dryml/dryml.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |s|
s.summary = "The Don't Repeat Yourself Markup Language"
s.description = "The Don't Repeat Yourself Markup Language"

s.add_runtime_dependency('actionpack')
s.add_runtime_dependency('actionpack', '~> 5')
s.add_runtime_dependency('hobo_support', ["= #{version}"])
# s.add_development_dependency('rubydoctest', [">= 1.1.3"])
s.add_development_dependency('cucumber', '~> 1.1.0')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ActionController::Base.class_eval do

before_filter do
before_action do
append_view_path Dryml::Railtie::PageTagResolver.new(self)
end

Expand Down
1 change: 0 additions & 1 deletion hobo/app/helpers/hobo_helper_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module HoboHelperBase

def add_to_controller(controller)
controller.send(:include, self)
controller.hide_action(self.instance_methods)
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class <%= subsite_name %>::<%= subsite_name %>SiteController < ApplicationContro

hobo_controller

before_filter :admin_required
before_action :admin_required

private

Expand Down
1 change: 1 addition & 0 deletions hobo/lib/generators/hobo/routes/routes_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class RoutesGenerator < Rails::Generators::Base

include Generators::HoboSupport::EvalTemplate


def self.banner
"rails generate hobo:routes #{self.arguments.map(&:usage).join(' ')} [options]"
end
Expand Down
11 changes: 11 additions & 0 deletions hobo/lib/generators/hobo/routes/templates/hobo_routes.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
# which will override the routes in this file.

<%= Rails.application.class.name %>.routes.draw do
begin
<%=
begin
::GearsModel.emit_custom_routes
rescue => e
''
end
%>
rescue ScriptError, StandardError => e
DT.p "Error in custom routes output, review hobo_routes.rb", e.message
end
<% for subsite in subsites -%>
<%- if subsite -%>

Expand Down
4 changes: 2 additions & 2 deletions hobo/lib/hobo/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def included(base)
def included_in_class(klass)
klass.extend(ClassMethods)
klass.class_eval do
before_filter :login_from_cookie
before_action :login_from_cookie
alias_method_chain :redirect_to, :object_url
private
def set_mailer_default_url_options
Expand All @@ -25,7 +25,7 @@ def set_mailer_default_url_options
Rails.application.config.action_mailer.default_url_options[:port] = request.port unless request.port == 80
end
end
before_filter :set_mailer_default_url_options
before_action :set_mailer_default_url_options
@included_taglibs = []
rescue_from ActionController::RoutingError, :with => :not_found unless Rails.env.development?
end
Expand Down
4 changes: 2 additions & 2 deletions hobo/lib/hobo/controller/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Model

include Hobo::Controller

DONT_PAGINATE_FORMATS = [ Mime::CSV, Mime::YAML, Mime::JSON, Mime::XML, Mime::ATOM, Mime::RSS ]
DONT_PAGINATE_FORMATS = [ Mime[:csv], Mime[:yaml], Mime[:json], Mime[:xml], Mime[:atom], Mime[:rss] ]

WILL_PAGINATE_OPTIONS = [ :page, :per_page, :total_entries, :count, :finder ]

Expand All @@ -25,7 +25,7 @@ def included(base)


helper_method :model, :current_user
before_filter :set_no_cache_headers
before_action :set_no_cache_headers

rescue_from ActiveRecord::RecordNotFound, :with => :not_found unless Rails.env.development?

Expand Down
2 changes: 1 addition & 1 deletion hobo/lib/hobo/controller/user_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class << self
alias_method_chain :def_auto_actions, :user_actions
end

skip_before_filter :login_required, :only => [:login, :signup, :do_signup, :forgot_password, :reset_password, :do_reset_password,
skip_before_action :login_required, :only => [:login, :signup, :do_signup, :forgot_password, :reset_password, :do_reset_password,
:accept_invitation, :do_accept_invitation]

alias_method_chain :hobo_update, :account_flash
Expand Down
20 changes: 3 additions & 17 deletions hobo/lib/hobo/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ def belongs_to_with_test_methods(name, *args, &block)
end
belongs_to_without_test_methods(name, *args, &block)
refl = reflections[name.to_s]
id_method = refl.options[:primary_key] || refl.klass.primary_key
id_method = refl.options[:primary_key]
id_method = refl.klass.primary_key if id_method.blank?
id_method = :id if id_method.blank?
if options[:polymorphic]
# TODO: the class lookup in _is? below is incomplete; a polymorphic association to an STI base class
# will fail to match an object of a derived type
Expand Down Expand Up @@ -185,7 +187,6 @@ def #{name}_changed?
end
end


def attr_accessor_with_creator_metadata(*args)
options = args.extract_options!
if options.delete(:creator)
Expand All @@ -199,24 +200,20 @@ def attr_accessor_with_creator_metadata(*args)
attr_accessor_without_creator_metadata(*args)
end


def has_one_with_new_method(name, options={}, &block)
has_one_without_new_method(name, options, &block)
class_eval "def new_#{name}(attributes={}); build_#{name}(attributes, false); end"
end


def set_default_order(order)
@default_order = order
end


def never_show(*fields)
@hobo_never_show ||= []
@hobo_never_show.concat(fields.*.to_sym)
end


def set_search_columns(*columns)
class_eval %{
def self.search_columns
Expand All @@ -225,39 +222,32 @@ def self.search_columns
}
end


public


def never_show?(field)
(@hobo_never_show && field.to_sym.in?(@hobo_never_show)) || (superclass < Hobo::Model && superclass.never_show?(field))
end


def find(*args)
result = super
result.member_class = self if result.is_a?(Array)
result
end


def find_by_sql(*args)
result = super
result
end


def creator_type
attr_type(creator_attribute)
end


def search_columns
column_names = columns.*.name
SEARCH_COLUMNS_GUESS.select{|c| c.in?(column_names) }
end


def reverse_reflection(association_name)
refl = reflections[association_name.to_s] or raise "No reverse reflection for #{name}.#{association_name}"
return nil if refl.options[:conditions] || refl.options[:polymorphic]
Expand Down Expand Up @@ -377,7 +367,6 @@ def set_creator(user)
set_creator!(user) unless get_creator
end


def set_creator!(user)
attr = self.class.creator_attribute
return unless attr
Expand All @@ -397,17 +386,14 @@ def set_creator!(user)
end
end


def get_creator
self.class.creator_attribute && send(self.class.creator_attribute)
end


def typed_id
"#{self.class.name.underscore}:#{self.id}" if id
end


def to_s
if self.class.name_attribute
send self.class.name_attribute
Expand Down
2 changes: 1 addition & 1 deletion hobo/lib/hobo/model/accessible_associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def #{name}_with_finder=(record_or_string)


# Add :accessible to the valid options so AR doesn't complain
::ActiveRecord::Associations::Builder::Association.valid_options << :accessible
::ActiveRecord::Associations::Builder::Association::VALID_OPTIONS << :accessible

end
end
Expand Down
2 changes: 1 addition & 1 deletion hobo/lib/hobo/model/scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Hobo
module Model
module Scopes

::ActiveRecord::Associations::Builder::Association.valid_options << :scope
::ActiveRecord::Associations::Builder::Association::VALID_OPTIONS << :scope

def self.included_in_class(klass)
klass.class_eval do
Expand Down
Loading