Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
fixed has settings conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Adams committed Feb 10, 2009
2 parents 703fcb2 + ee2a465 commit 5a64e82
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
3 changes: 2 additions & 1 deletion README.markdown
Expand Up @@ -18,6 +18,7 @@ Ansuz is licensed via the BSD license.
## Quick Start

1. clone from github: git clone git://github.com/knewter/ansuz.git
2. install gems: sudo rake gems:install
2. rake ansuz:install

NOTE: SQLite has problems with ansuz, please don't use it for now.
Expand All @@ -31,7 +32,7 @@ for the domain specified. So, then if that domain points to the server, Bam! Don

## This software is BSD licensed. See the COPYING file for details.

For help, feel free to contact the authors at:
For help, feel free to contact the authors at [Our Google Gorup](http://groups.google.com/group/ansuz-cms), or individually:

- josh at isotope11.com
- james at isotope11.com
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20081123161548_add_status_to_pages.rb
@@ -1,6 +1,6 @@
class AddStatusToPages < ActiveRecord::Migration
def self.up
add_index :pages, :status
#add_index :pages, :status
# TODO: This needs to be moved to an 'initial setup' rake task
Page.create(
:name => 'home',
Expand All @@ -19,6 +19,6 @@ def self.up
end

def self.down
remove_index :pages, :column => :status
#remove_index :pages, :column => :status
end
end
8 changes: 5 additions & 3 deletions lib/tasks/ansuz.rake
Expand Up @@ -3,7 +3,7 @@ require "yaml"
namespace :ansuz do
desc "Set the CMS theme"
task(:choose_theme => :environment) do
themes = Dir.entries( File.join(RAILS_ROOT, "public", "themes")).select{|d| d =~ /^\w|^\d/}.collect{|theme| theme="- #{theme}"}
themes = Dir.entries( File.join(RAILS_ROOT, "themes")).select{|d| d =~ /^\w|^\d/}.collect{|theme| theme="- #{theme}"}
if( themes.any? )
STDOUT.puts "[ansuz] Themes:\n" + themes.join("\n")
STDOUT.puts "[ansuz] Enter a selection above, or leave blank for default"
Expand All @@ -19,6 +19,7 @@ namespace :ansuz do
else
STDOUT.puts "[ansuz] No themes available!"
end

end

# Called at the beginning of the initializer in config/environment.rb before Rails complains about not having a db"
Expand Down Expand Up @@ -122,9 +123,8 @@ namespace :ansuz do
STDOUT.flush
password = $stdin.gets.chomp
u = User.new :login => 'admin', :email => 'admin@example.com', :password => password, :password_confirmation => password
u.save
u.has_role 'admin'
u.save # Not sure why we save twice. Josh?
u.save
STDOUT.puts "[ansuz] Admin user created with login 'admin' and the password you entered."
else
STDOUT.puts "[ansuz] Admin user already exists."
Expand All @@ -134,6 +134,8 @@ namespace :ansuz do
unless( File.directory?( File.join(RAILS_ROOT, "public", "uploads") ) )
STDOUT.puts "[ansuz] Creating public/uploads directory for FCKeditor.."
FileUtils.mkdir( File.join(RAILS_ROOT, "public", "uploads") )
else
STDOUT.puts "[ansuz] public/uploads directory for FCKeditor already exists."
end

Rake::Task["ansuz:choose_theme"].invoke
Expand Down
40 changes: 21 additions & 19 deletions vendor/plugins/has_settings/lib/has_settings.rb
Expand Up @@ -22,29 +22,31 @@ module ClassMethods
# >> w.reload
# >> w.settings["foo"] #=> "bar
def has_settings
has_one :has_settings_setting, :as => "configurable"
after_save :save_settings
if ActiveRecord::Base.connection.table_exists?('has_settings_settings')
has_one :has_settings_setting, :as => "configurable"
after_save :save_settings

define_method "settings" do |*args|
@the_has_settings_setting ||= get_has_settings_setting
@the_has_settings_setting.settings || {}
end
define_method "settings" do |*args|
@the_has_settings_setting ||= get_has_settings_setting
@the_has_settings_setting.settings || {}
end

define_method "settings=" do |the_settings|
self.get_has_settings_setting
self.has_settings_setting.settings = the_settings
end
define_method "settings=" do |the_settings|
self.get_has_settings_setting
self.has_settings_setting.settings = the_settings
end

define_method "save_settings" do
get_has_settings_setting.save unless new_record?
end
define_method "save_settings" do
get_has_settings_setting.save unless new_record?
end

define_method "get_has_settings_setting" do
if self.has_settings_setting
self.has_settings_setting
else
self.has_settings_setting = HasSettingsSetting.new :settings => {}
self.has_settings_setting
define_method "get_has_settings_setting" do
if self.has_settings_setting
self.has_settings_setting
else
self.has_settings_setting = HasSettingsSetting.new :settings => {}
self.has_settings_setting
end
end
end
end
Expand Down

0 comments on commit 5a64e82

Please sign in to comment.