Commit 7cdd88a6 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Merged Rails 2.1 compatibility branch.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1623 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 22558f77
...@@ -52,7 +52,7 @@ class ProjectsController < ApplicationController ...@@ -52,7 +52,7 @@ class ProjectsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { format.html {
@project_tree = projects.group_by {|p| p.parent || p} @project_tree = projects.group_by {|p| p.parent || p}
@project_tree.each_key {|p| @project_tree[p] -= [p]} @project_tree.keys.each {|p| @project_tree[p] -= [p]}
} }
format.atom { format.atom {
render_feed(projects.sort_by(&:created_on).reverse.slice(0, Setting.feeds_limit.to_i), render_feed(projects.sort_by(&:created_on).reverse.slice(0, Setting.feeds_limit.to_i),
......
...@@ -22,6 +22,10 @@ module RepositoriesHelper ...@@ -22,6 +22,10 @@ module RepositoriesHelper
txt.to_s[0,8] txt.to_s[0,8]
end end
def to_path_param(path)
path.to_s.split(%r{[/\\]}).select {|p| !p.blank?}
end
def to_utf8(str) def to_utf8(str)
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
@encodings ||= Setting.repositories_encodings.split(',').collect(&:strip) @encodings ||= Setting.repositories_encodings.split(',').collect(&:strip)
......
...@@ -42,8 +42,10 @@ class UserPreference < ActiveRecord::Base ...@@ -42,8 +42,10 @@ class UserPreference < ActiveRecord::Base
if attribute_present? attr_name if attribute_present? attr_name
super super
else else
self.others ||= {} h = read_attribute(:others).dup || {}
self.others.store attr_name, value h.update(attr_name => value)
write_attribute(:others, h)
value
end end
end end
......
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
<tr id="<%= tr_id %>" class="<%= params[:parent_id] %> entry <%= entry.kind %>"> <tr id="<%= tr_id %>" class="<%= params[:parent_id] %> entry <%= entry.kind %>">
<td style="padding-left: <%=18 * depth%>px;" class="filename"> <td style="padding-left: <%=18 * depth%>px;" class="filename">
<% if entry.is_dir? %> <% if entry.is_dir? %>
<span class="expander" onclick="<%= remote_function :url => {:action => 'browse', :id => @project, :path => entry.path, :rev => @rev, :depth => (depth + 1), :parent_id => tr_id}, <span class="expander" onclick="<%= remote_function :url => {:action => 'browse', :id => @project, :path => to_path_param(entry.path), :rev => @rev, :depth => (depth + 1), :parent_id => tr_id},
:update => { :success => tr_id }, :update => { :success => tr_id },
:position => :after, :position => :after,
:success => "scmEntryLoaded('#{tr_id}')", :success => "scmEntryLoaded('#{tr_id}')",
:condition => "scmEntryClick('#{tr_id}')"%>">&nbsp</span> :condition => "scmEntryClick('#{tr_id}')"%>">&nbsp</span>
<% end %> <% end %>
<%= link_to h(entry.name), <%= link_to h(entry.name),
{:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => entry.path, :rev => @rev}, {:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => to_path_param(entry.path), :rev => @rev},
:class => (entry.is_dir? ? 'icon icon-folder' : 'icon icon-file')%> :class => (entry.is_dir? ? 'icon icon-folder' : 'icon icon-file')%>
</td> </td>
<td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td> <td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>
......
...@@ -10,10 +10,10 @@ dirs.each do |dir| ...@@ -10,10 +10,10 @@ dirs.each do |dir|
link_path << '/' unless link_path.empty? link_path << '/' unless link_path.empty?
link_path << "#{dir}" link_path << "#{dir}"
%> %>
/ <%= link_to h(dir), :action => 'browse', :id => @project, :path => link_path, :rev => @rev %> / <%= link_to h(dir), :action => 'browse', :id => @project, :path => to_path_param(link_path), :rev => @rev %>
<% end %> <% end %>
<% if filename %> <% if filename %>
/ <%= link_to h(filename), :action => 'changes', :id => @project, :path => "#{link_path}/#{filename}", :rev => @rev %> / <%= link_to h(filename), :action => 'changes', :id => @project, :path => to_path_param("#{link_path}/#{filename}"), :rev => @rev %>
<% end %> <% end %>
<%= "@ #{revision}" if revision %> <%= "@ #{revision}" if revision %>
......
<% form_tag({:controller => 'repositories', :action => 'diff', :id => @project, :path => path}, :method => :get) do %> <% form_tag({:controller => 'repositories', :action => 'diff', :id => @project, :path => to_path_param(path)}, :method => :get) do %>
<table class="list changesets"> <table class="list changesets">
<thead><tr> <thead><tr>
<th>#</th> <th>#</th>
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
<p> <p>
<% if @repository.supports_cat? %> <% if @repository.supports_cat? %>
<%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => @path, :rev => @rev } %> | <%= link_to l(:button_view), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev } %> |
<% end %> <% end %>
<% if @repository.supports_annotate? %> <% if @repository.supports_annotate? %>
<%= link_to l(:button_annotate), {:action => 'annotate', :id => @project, :path => @path, :rev => @rev } %> | <%= link_to l(:button_annotate), {:action => 'annotate', :id => @project, :path => to_path_param(@path), :rev => @rev } %> |
<% end %> <% end %>
<%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %> <%= link_to(l(:button_download), {:action => 'entry', :id => @project, :path => to_path_param(@path), :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %>
<%= "(#{number_to_human_size(@entry.size)})" if @entry.size %> <%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
</p> </p>
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
<%= "(#{change.revision})" unless change.revision.blank? %></td> <%= "(#{change.revision})" unless change.revision.blank? %></td>
<td align="right"> <td align="right">
<% if change.action == "M" %> <% if change.action == "M" %>
<%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => without_leading_slash(change.relative_path), :rev => @changeset.revision %> <%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => to_path_param(change.relative_path), :rev => @changeset.revision %>
<% end %> <% end %>
</td> </td>
</tr> </tr>
......
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb # Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
unless defined?(RAILS_ROOT) RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
root_path = File.join(File.dirname(__FILE__), '..')
unless RUBY_PLATFORM =~ /mswin32/ module Rails
require 'pathname' class << self
root_path = Pathname.new(root_path).cleanpath(true).to_s def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
defined? Rails::Initializer
end
def pick_boot
(vendor_rails? ? VendorBoot : GemBoot).new
end
def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
end
def preinitialize
load(preinitializer_path) if File.exist?(preinitializer_path)
end
def preinitializer_path
"#{RAILS_ROOT}/config/preinitializer.rb"
end
end end
RAILS_ROOT = root_path
end
if File.directory?("#{RAILS_ROOT}/vendor/rails") class Boot
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" def run
else load_initializer
require 'rubygems' Rails::Initializer.run(:set_load_path)
require 'initializer' end
end
class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
end
end
class GemBoot < Boot
def load_initializer
self.class.load_rubygems
load_rails_gem
require 'initializer'
end
def load_rails_gem
if version = self.class.gem_version
gem 'rails', version
else
gem 'rails'
end
rescue Gem::LoadError => load_error
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
exit 1
end
class << self
def rubygems_version
Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
end
def gem_version
if defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION
elsif ENV.include?('RAILS_GEM_VERSION')
ENV['RAILS_GEM_VERSION']
else
parse_gem_version(read_environment_rb)
end
end
def load_rubygems
require 'rubygems'
unless rubygems_version >= '0.9.4'
$stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end
rescue LoadError
$stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end
def parse_gem_version(text)
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
end
private
def read_environment_rb
File.read("#{RAILS_ROOT}/config/environment.rb")
end
end
end
end end
Rails::Initializer.run(:set_load_path) # All that for this:
Rails.boot!
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production' # ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present # Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration # Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot') require File.join(File.dirname(__FILE__), 'boot')
...@@ -71,32 +71,3 @@ Rails::Initializer.run do |config| ...@@ -71,32 +71,3 @@ Rails::Initializer.run do |config|
config.action_mailer.delivery_method = :smtp config.action_mailer.delivery_method = :smtp
end end
ActiveRecord::Errors.default_error_messages = {
:inclusion => "activerecord_error_inclusion",
:exclusion => "activerecord_error_exclusion",
:invalid => "activerecord_error_invalid",
:confirmation => "activerecord_error_confirmation",
:accepted => "activerecord_error_accepted",
:empty => "activerecord_error_empty",
:blank => "activerecord_error_blank",
:too_long => "activerecord_error_too_long",
:too_short => "activerecord_error_too_short",
:wrong_length => "activerecord_error_wrong_length",
:taken => "activerecord_error_taken",
:not_a_number => "activerecord_error_not_a_number"
}
ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
Mime::SET << Mime::CSV unless Mime::SET.include?(Mime::CSV)
Mime::Type.register 'application/pdf', :pdf
GLoc.set_config :default_language => :en
GLoc.clear_strings
GLoc.set_kcode
GLoc.load_localized_strings
GLoc.set_config(:raise_string_not_found_errors => false)
require 'redmine'
ActiveRecord::Errors.default_error_messages = {
:inclusion => "activerecord_error_inclusion",
:exclusion => "activerecord_error_exclusion",
:invalid => "activerecord_error_invalid",
:confirmation => "activerecord_error_confirmation",
:accepted => "activerecord_error_accepted",
:empty => "activerecord_error_empty",
:blank => "activerecord_error_blank",
:too_long => "activerecord_error_too_long",
:too_short => "activerecord_error_too_short",
:wrong_length => "activerecord_error_wrong_length",
:taken => "activerecord_error_taken",
:not_a_number => "activerecord_error_not_a_number"
}
ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
# Add new mime types for use in respond_to blocks:
Mime::SET << Mime::CSV unless Mime::SET.include?(Mime::CSV)
Mime::Type.register 'application/pdf', :pdf
GLoc.set_config :default_language => :en
GLoc.clear_strings
GLoc.set_kcode
GLoc.load_localized_strings
GLoc.set_config(:raise_string_not_found_errors => false)
require 'redmine'
class AddEnumerationsPosition < ActiveRecord::Migration class AddEnumerationsPosition < ActiveRecord::Migration
def self.up def self.up
add_column(:enumerations, :position, :integer, :default => 1) unless Enumeration.column_names.include?('position') add_column(:enumerations, :position, :integer, :default => 1) unless Enumeration.column_names.include?('position')
Enumeration.find(:all).group_by(&:opt).each_value do |enums| Enumeration.find(:all).group_by(&:opt).each do |opt, enums|
enums.each_with_index do |enum, i| enums.each_with_index do |enum, i|
# do not call model callbacks # do not call model callbacks
Enumeration.update_all "position = #{i+1}", {:id => enum.id} Enumeration.update_all "position = #{i+1}", {:id => enum.id}
......
class AddCustomFieldsPosition < ActiveRecord::Migration class AddCustomFieldsPosition < ActiveRecord::Migration
def self.up def self.up
add_column(:custom_fields, :position, :integer, :default => 1) add_column(:custom_fields, :position, :integer, :default => 1)
CustomField.find(:all).group_by(&:type).each_value do |fields| CustomField.find(:all).group_by(&:type).each do |t, fields|
fields.each_with_index do |field, i| fields.each_with_index do |field, i|
# do not call model callbacks # do not call model callbacks
CustomField.update_all "position = #{i+1}", {:id => field.id} CustomField.update_all "position = #{i+1}", {:id => field.id}
......
...@@ -22,7 +22,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder ...@@ -22,7 +22,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
def initialize(object_name, object, template, options, proc) def initialize(object_name, object, template, options, proc)
set_language_if_valid options.delete(:lang) set_language_if_valid options.delete(:lang)
@object_name, @object, @template, @options, @proc = object_name, object, template, options, proc super
end end
(field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector| (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
......
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
...@@ -38,7 +38,7 @@ class ProjectsControllerTest < Test::Unit::TestCase ...@@ -38,7 +38,7 @@ class ProjectsControllerTest < Test::Unit::TestCase
assert_template 'index' assert_template 'index'
assert_not_nil assigns(:project_tree) assert_not_nil assigns(:project_tree)
# Root project as hash key # Root project as hash key
assert assigns(:project_tree).has_key?(Project.find(1)) assert assigns(:project_tree).keys.include?(Project.find(1))
# Subproject in corresponding value # Subproject in corresponding value
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3)) assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
end end
......
...@@ -20,8 +20,11 @@ require "#{File.dirname(__FILE__)}/../test_helper" ...@@ -20,8 +20,11 @@ require "#{File.dirname(__FILE__)}/../test_helper"
class IssuesTest < ActionController::IntegrationTest class IssuesTest < ActionController::IntegrationTest
fixtures :projects, fixtures :projects,
:users, :users,
:roles,
:members,
:trackers, :trackers,
:projects_trackers, :projects_trackers,
:enabled_modules,
:issue_statuses, :issue_statuses,
:issues, :issues,
:enumerations, :enumerations,
......
...@@ -65,20 +65,3 @@ class Test::Unit::TestCase ...@@ -65,20 +65,3 @@ class Test::Unit::TestCase
Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments" Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments"
end end
end end
# ActionController::TestUploadedFile bug
# see http://dev.rubyonrails.org/ticket/4635
class String
def original_filename
"testfile.txt"
end
def content_type
"text/plain"
end
def read
self.to_s
end
end
...@@ -26,7 +26,7 @@ class RoleTest < Test::Unit::TestCase ...@@ -26,7 +26,7 @@ class RoleTest < Test::Unit::TestCase
target = Role.new(:name => 'Target') target = Role.new(:name => 'Target')
assert target.save assert target.save
assert target.workflows.copy(source) target.workflows.copy(source)
target.reload target.reload
assert_equal 90, target.workflows.size assert_equal 90, target.workflows.size
end end
......
...@@ -26,7 +26,7 @@ class TrackerTest < Test::Unit::TestCase ...@@ -26,7 +26,7 @@ class TrackerTest < Test::Unit::TestCase
target = Tracker.new(:name => 'Target') target = Tracker.new(:name => 'Target')
assert target.save assert target.save
assert target.workflows.copy(source) target.workflows.copy(source)
target.reload target.reload
assert_equal 89, target.workflows.size assert_equal 89, target.workflows.size
end end
......
This diff is collapsed.
$:.unshift(File.dirname(__FILE__) + '/../../../rails/activesupport/lib')
$:.unshift(File.dirname(__FILE__) + '/../../../rails/activerecord/lib')
$:.unshift(File.dirname(__FILE__) + '/../lib') $:.unshift(File.dirname(__FILE__) + '/../lib')
require 'test/unit' require 'test/unit'
require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb')) begin
require 'active_record/fixtures' require 'active_support'
require 'active_record'
require 'active_record/fixtures'
rescue LoadError
require 'rubygems'
retry
end
require 'acts_as_versioned'
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log") ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
ActiveRecord::Base.establish_connection(config[ENV['DB'] || 'sqlite']) ActiveRecord::Base.configurations = {'test' => config[ENV['DB'] || 'sqlite3']}
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
load(File.dirname(__FILE__) + "/schema.rb") load(File.dirname(__FILE__) + "/schema.rb")
...@@ -19,17 +28,9 @@ if ENV['DB'] == 'postgresql' ...@@ -19,17 +28,9 @@ if ENV['DB'] == 'postgresql'
end end
Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/" Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
$LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path) $:.unshift(Test::Unit::TestCase.fixture_path)
class Test::Unit::TestCase #:nodoc: class Test::Unit::TestCase #:nodoc:
def create_fixtures(*table_names)
if block_given?
Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
else
Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
end
end
# Turn off transactional fixtures if you're working with MyISAM tables in MySQL # Turn off transactional fixtures if you're working with MyISAM tables in MySQL
self.use_transactional_fixtures = true self.use_transactional_fixtures = true
......
class Widget < ActiveRecord::Base class Widget < ActiveRecord::Base
acts_as_versioned :sequence_name => 'widgets_seq', :association_options => { acts_as_versioned :sequence_name => 'widgets_seq', :association_options => {
:dependent => nil, :order => 'version desc' :dependent => :nullify, :order => 'version desc'
} }
non_versioned_columns << 'foo' non_versioned_columns << 'foo'
end end
\ No newline at end of file
...@@ -9,9 +9,14 @@ if ActiveRecord::Base.connection.supports_migrations? ...@@ -9,9 +9,14 @@ if ActiveRecord::Base.connection.supports_migrations?
class MigrationTest < Test::Unit::TestCase class MigrationTest < Test::Unit::TestCase
self.use_transactional_fixtures = false self.use_transactional_fixtures = false
def teardown def teardown
ActiveRecord::Base.connection.initialize_schema_information if ActiveRecord::Base.connection.respond_to?(:initialize_schema_information)
ActiveRecord::Base.connection.update "UPDATE schema_info SET version = 0" ActiveRecord::Base.connection.initialize_schema_information
ActiveRecord::Base.connection.update "UPDATE schema_info SET version = 0"
else
ActiveRecord::Base.connection.initialize_schema_migrations_table
ActiveRecord::Base.connection.assume_migrated_upto_version(0)
end
Thing.connection.drop_table "things" rescue nil Thing.connection.drop_table "things" rescue nil
Thing.connection.drop_table "thing_versions" rescue nil Thing.connection.drop_table "thing_versions" rescue nil
Thing.reset_column_information Thing.reset_column_information
...@@ -21,8 +26,17 @@ if ActiveRecord::Base.connection.supports_migrations? ...@@ -21,8 +26,17 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_raises(ActiveRecord::StatementInvalid) { Thing.create :title => 'blah blah' } assert_raises(ActiveRecord::StatementInvalid) { Thing.create :title => 'blah blah' }
# take 'er up # take 'er up
ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/') ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/')
t = Thing.create :title => 'blah blah' t = Thing.create :title => 'blah blah', :price => 123.45, :type => 'Thing'
assert_equal 1, t.versions.size assert_equal 1, t.versions.size
# check that the price column has remembered its value correctly
assert_equal t.price, t.versions.first.price
assert_equal t.title, t.versions.first.title
assert_equal t[:type], t.versions.first[:type]
# make sure that the precision of the price column has been preserved
assert_equal 7, Thing::Version.columns.find{|c| c.name == "price"}.precision
assert_equal 2, Thing::Version.columns.find{|c| c.name == "price"}.scale
# now lets take 'er back down # now lets take 'er back down
ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/fixtures/migrations/') ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/fixtures/migrations/')
......
require 'rfpdf' require 'rfpdf'
ActionView::Base::register_template_handler 'rfpdf', RFPDF::View begin
\ No newline at end of file ActionView::Template::register_template_handler 'rfpdf', RFPDF::View
rescue NameError
# Rails < 2.1
RFPDF::View.backward_compatibility_mode = true
ActionView::Base::register_template_handler 'rfpdf', RFPDF::View
end
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
module RFPDF module RFPDF
class View class View
@@backward_compatibility_mode = false
cattr_accessor :backward_compatibility_mode
def initialize(action_view) def initialize(action_view)
@action_view = action_view @action_view = action_view
...@@ -45,6 +47,14 @@ module RFPDF ...@@ -45,6 +47,14 @@ module RFPDF
:temp_dir => "#{File.expand_path(RAILS_ROOT)}/tmp" :temp_dir => "#{File.expand_path(RAILS_ROOT)}/tmp"
}.merge(@action_view.controller.instance_eval{ @options_for_rfpdf } || {}).with_indifferent_access }.merge(@action_view.controller.instance_eval{ @options_for_rfpdf } || {}).with_indifferent_access
end end
def self.compilable?
false
end
def compilable?
self.class.compilable?
end
def render(template, local_assigns = {}) def render(template, local_assigns = {})
@pdf_name = "Default.pdf" if @pdf_name.nil? @pdf_name = "Default.pdf" if @pdf_name.nil?
...@@ -66,7 +76,7 @@ module RFPDF ...@@ -66,7 +76,7 @@ module RFPDF
local_assigns.each do |key,val| local_assigns.each do |key,val|
class << self; self; end.send(:define_method,key){ val } class << self; self; end.send(:define_method,key){ val }
end end
ERB.new(template).result(binding) ERB.new(@@backward_compatibility_mode == true ? template : template.source).result(binding)
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment