Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Don't hard code users table for auto subscription option #203

merged 1 commit into from

5 participants


No description provided.


Looks good to me cc @radar @knewter


I was also wondering if setting up a store for this (and future?) user settings would make sense so every new setting doesn't need another column.


Ah good catch. How would you suggest storing forem user settings? As a JSON blob?


I was thinking of using ActiveRecord::Store which serializes to json I believe.


Where would we use ActiveSupport::Concern? If we wanted to add settings to multiple models?


Wait - what sort of user are you talking about? I think of users like developers sometimes which I think is wrong in this case? ;-)


Sorry, I was talking about forem end-users. I could see them having more options in the future (and potentially a front-end to edit these options) in addition to this "auto-subscribe" option.


ActiveRecord::Store looks good. Should we do it immediately or wait for people to figure out what other sorts of settings users might need?

Another setting I thought of is an email setting (do you want to receive emails from administrators? etc)


Let's wait and see what the forem team thinks. Not a huge deal, just trying to cut down on the number of migrations needed going forward


+1 on "we need a more generic settings system"

To use rails properly, this is ideal here:


@parndt parndt merged commit e2afb83 into radar:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
5 db/migrate/20120414183053_add_forem_auto_subscribe_to_user.rb
@@ -1,5 +0,0 @@
-class AddForemAutoSubscribeToUser < ActiveRecord::Migration
- def change
- add_column :users, :forem_auto_subscribe, :boolean, :default => false
- end
6 lib/generators/forem/install/templates/forem_auto_subscribe_migration.rb
@@ -0,0 +1,6 @@
+class AddForemAutoSubscribeToUser < ActiveRecord::Migration
+ def change
+ add_column <%= user_class.constantize.table_name.to_sym.inspect %>, :forem_auto_subscribe, :boolean, :default => false
+ end
5 lib/generators/forem/install_generator.rb
@@ -44,6 +44,11 @@ def add_forem_state_migration
template "forem_state_migration.rb", "#{Rails.root}/db/migrate/#{next_migration_number}_add_forem_state.rb"
+ def add_forem_autosubscribe_migration
+ puts "Adding forem_auto_subscribe migration..."
+ template "forem_auto_subscribe_migration.rb", "#{Rails.root}/db/migrate/#{next_migration_number}_add_forem_state.rb"
+ end
def determine_current_user_helper
if options["current-user-helper"]
current_user_helper = options["current-user-helper"]
8 spec/generators/install_generator_spec.rb
@@ -53,13 +53,17 @@ def migrations
migrations.should_not be_empty
# Ensure forem admin migration has been created
- forem_admin_migration = File.readlines(migrations[-2])
+ forem_admin_migration = File.readlines(migrations[-3])
forem_admin_migration[3].strip.should == "add_column :users, :forem_admin, :boolean, :default => false"
# Ensure forem state migration has been created
- forem_state_migration = File.readlines(migrations[-1])
+ forem_state_migration = File.readlines(migrations[-2])
forem_state_migration[3].strip.should == "add_column :users, :forem_state, :string, :default => 'pending_review'"
+ # Ensure forem auto subscribe migration has been created
+ forem_state_migration = File.readlines(migrations[-1])
+ forem_state_migration[3].strip.should == "add_column :users, :forem_auto_subscribe, :boolean, :default => false"
# Ensure initializer has been created
forem_initializer = File.readlines("#{Rails.root}/config/initializers/forem.rb")
forem_initializer[0].strip.should == "Forem.user_class = 'User'"
1  spec/lib/generators/forem/dummy/templates/db/migrate/1_create_users.rb
@@ -5,6 +5,7 @@ class CreateUsers < ActiveRecord::Migration
t.string :login
t.boolean :forem_admin, :default => false
t.string :forem_state, :default => "pending_review"
+ t.boolean :forem_auto_subscribe, :default => false
t.string :users, :custom_avatar_url
Something went wrong with that request. Please try again.