Code Monkey home page Code Monkey logo

rails-settings's Introduction

Settings for Rails

Build Status Code Climate Coverage Status

Ruby gem to handle settings for ActiveRecord instances by storing them as serialized Hash in a separate database table. Namespaces and defaults included.

Requirements

  • Ruby 3.0 or newer
  • Rails 6.1 or newer (including Rails 7.0)

Installation

Include the gem in your Gemfile and run bundle to install it:

gem 'ledermann-rails-settings'

Generate and run the migration:

rails g rails_settings:migration
rake db:migrate

Usage

Define settings

class User < ActiveRecord::Base
  has_settings do |s|
    s.key :dashboard, :defaults => { :theme => 'blue', :view => 'monthly', :filter => false }
    s.key :calendar,  :defaults => { :scope => 'company'}
  end
end

If no defaults are needed, a simplified syntax can be used:

class User < ActiveRecord::Base
  has_settings :dashboard, :calendar
end

Every setting is handled by the class RailsSettings::SettingObject. You can use your own class, e.g. for validations:

class Project < ActiveRecord::Base
  has_settings :info, :class_name => 'ProjectSettingObject'
end

class ProjectSettingObject < RailsSettings::SettingObject
  validate do
    unless self.owner_name.present? && self.owner_name.is_a?(String)
      errors.add(:base, "Owner name is missing")
    end
  end
end

In case you need to define settings separatedly for the same models, you can use the persistent option

module UserDashboardConcern
  extend ActiveSupport::Concern

  included do
    has_settings persistent: true do |s|
      s.key :dashboard
    end
  end
end

class User < ActiveRecord::Base
  has_settings persistent: true do |s|
    s.key :calendar
  end
end

Set settings

user = User.find(1)
user.settings(:dashboard).theme = 'black'
user.settings(:calendar).scope = 'all'
user.settings(:calendar).display = 'daily'
user.save! # saves new or changed settings, too

or

user = User.find(1)
user.settings(:dashboard).update! :theme => 'black'
user.settings(:calendar).update! :scope => 'all', :display => 'daily'

Get settings

user = User.find(1)
user.settings(:dashboard).theme
# => 'black

user.settings(:dashboard).view
# => 'monthly'  (it's the default)

user.settings(:calendar).scope
# => 'all'

Delete settings

user = User.find(1)
user.settings(:dashboard).update! :theme => nil

user.settings(:dashboard).view = nil
user.settings(:dashboard).save!

Using scopes

User.with_settings
# => all users having any setting

User.without_settings
# => all users without having any setting

User.with_settings_for(:calendar)
# => all users having a setting for 'calendar'

User.without_settings_for(:calendar)
# => all users without having settings for 'calendar'

Eager Loading

User.includes(:setting_objects)
# => Eager load setting_objects when querying many users

Compatibility

Version 2 is a complete rewrite and has a new DSL, so it's not compatible with Version 1. In addition, Rails 2.3 is not supported anymore. But the database schema is unchanged, so you can continue to use the data created by 1.x, no conversion is needed.

If you don't want to upgrade, you find the old version in the 1.x branch. But don't expect any updates there.

Changelog

See https://github.com/ledermann/rails-settings/releases

License

MIT License

Copyright (c) 2012-2023 Georg Ledermann

This gem is a complete rewrite of rails-settings by Alex Wayne

rails-settings's People

Contributors

alexjwayne avatar doncote avatar farkmarnum avatar hankwallace avatar jimryan avatar ledermann avatar marcferna avatar mceachen avatar mduong avatar mguymon avatar michaelklishin avatar mikker avatar nicbet avatar nicolaiespresso avatar proteusvacuum avatar schneiderl avatar vishalzambre avatar yemartin avatar zmillman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rails-settings's Issues

has_settings apparently not working

I must be missing something. I added has_settings to a model, then in the console do

s = TheShop.last    # load the model
s.settings.color = :red 
s.settings.color # returns nil

When I check the log, the target_id and target_type are passed as NULL, so the values are stored as global rather than specific to the model.

Querying for records with specific settings

The available scopes currently allow querying records which do/do not have settings of a specific type.

How could we retrieve all records where a specific setting matches the supplied value, whether having been explicitly set, or falling back to the "default" configuration? The with_settings_for(:symbol) (for example) only identifies whether the setting is set.

Example: Suppose this gem is used to track the various email delivery options for a user:

# app/models/user.rb
has_settings do |s|
  s.key :email_notifications, defaults: {
    account_updates: 'daily',
    newsletter: true
  }
end
# user controller's `update` action, when user opts in/out of newsletter emails
@user.settings(:email_notifications).newsletter = true # or false

What would be the best way to identify all users who are "opted in" to the newsletter, either explicitly (having set their settings), or by default? The current scopes do not support this.

My (perhaps somewhat ugly!) custom query achieving this is as follows:

@my_users.joins(%(
  LEFT OUTER JOIN settings
  ON  settings.target_type = 'User'
  AND settings.target_id = users.id
))
.where(%(
  (settings.var = 'email_notifications' AND settings.value LIKE '%newsletter: true%')
  OR settings.value IS NULL'
))

The equivalent for retrieving all users who have opted out, is a little simpler:

@my_users.joins(%(
  INNER JOIN settings
  ON  settings.target_type = 'User'
  AND settings.target_id = users.id
))
.where("settings.var = 'email_notifications'")
.where("settings.value LIKE '%newsletter: false%'")

This query retrieves all users which have either not defined their :email_notifications settings at all, or who have defined newsletter = true as above.

Do these sound like valid/useful candidates for new out-of-the-box scopes?

Save keys as provided type

When I am saving a boolean or integer setting, it is converting it to a string and not converting it BACK when reading the settings. This is massively problematic if I do something like

user.settings(:general).show_pic = false

and then later

if user.settings(:general).show_pic 
  # show pic...

Feature Request: Default settings for models

Right now you can set default settings like:

Settings.defaults[:my_setting] = default_setting

It would be great if it was possible to set defaults for models that have settings through has_settings too! E.g.

User.settings.defaults[:my_user_setting] = default_setting

has_settings for sub classes doesn't work

in case when A < ActiveRecord::Base and B < A has_settings doesn't work correct inside B.
Probably this is caused because target_type use base_class which will return A even if called inside B.
so _target_class will return wrong class and settings always will be nil.

I think overriding of target_type should solve problem, but I have not tested it well yet.

    def target_type
      target.class.to_s
    end

How do I use this in my Rails app?

I'm not sure how to use this in a Rails app that I'm going to deploy to Heroku. The instructions I've read about using forked gems involve a gemspec file, but your version doesn't have a gemspec file anymore.

Is there another method to use this that I'm missing?

I can't install it

Hi, Please could you put the line of your Gemfile in readme, because I can't install it
gem 'rails_settings', :git => "git://github.com/ledermann/rails-settings.git"

Tell me :

Could not find gem 'rails-settings (>= 0)' in git://github.com/ledermann/rails-settings.git (at master).
Source does not contain any versions of 'rails-settings (>= 0)'

Thanks.

Rails 4 support?

I don't see any forks advertising rails 4 support—have you entertained that yet?

Thanks for maintaining your fork, sir—much appreciated.

Dynamic saving settings

i am building an app and want to give the users the possibility to change there settings, so i want to save from a form with this code:

params[:settings].each do |key, value|
Settings.instance_variable_set("@#{key}", value)
end

do i need to call a save method??
Settings.save?

Because it wont work like this...

String not matched

Hi,

I used settings in my User model. But when I try to set variable, it always raise IndexError: string not matched, and gives follow information:

from /Users/stevenyue/.rvm/gems/ruby-1.9.3-p392@global/gems/ledermann-rails-settings-2.0.1/lib/rails-settings/setting_object.rb:59:in `[]='
from /Users/stevenyue/.rvm/gems/ruby-1.9.3-p392@global/gems/ledermann-rails-settings-2.0.1/lib/rails-settings/setting_object.rb:59:in `_set_value'
from /Users/stevenyue/.rvm/gems/ruby-1.9.3-p392@global/gems/ledermann-rails-settings-2.0.1/lib/rails-settings/setting_object.rb:32:in `method_missing'
from (irb):3
from /Users/stevenyue/.rvm/gems/ruby-1.9.3-p392@global/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /Users/stevenyue/.rvm/gems/ruby-1.9.3-p392@global/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /Users/stevenyue/.rvm/gems/ruby-1.9.3-p392@global/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

I followed exactly the same installation and settings in the instructions.

has_settings do |s|
s.key :dashboard, :defaults => { :theme => 'blue', :view => 'monthly', :filter => false }
s.key :calendar,  :defaults => { :scope => 'company'}
end

I can get the value by using

user = User.find(1)
user.settings(:dashboard).theme

But I can't set value using either way you provided.

I'm using rails 3.2.11, and the User model is generated by devise

Thanks

Global setting is updated for an unsaved activerecord

I'm using ledermann-rails-settings v1.2.0

I have a subscription model which has_settings

> Subscription.settings[:test]
 => nil

> subscription = Subscription.new
> subscription.settings[:test] = 1
# notice that I do not save subscription
> Subscription.settings[:test]
 => 1

This is really disturbing because if another user wants to add a new subscription, the default settings for :test will now be 1.

Reading the defaults even when the settings table is not yet created.

Hi Ledermann,

Right now, the can set the default value when the settings table is not created. Can it be possible for the reading the default value too? Because sometimes we need to read and write some configuration values in the initializers, when the table is not yet created.

quyen

Including :settings in to_json

Hi,

I'm wondering if there is a way to include the settings.all hash when you're converting a user object to JSON, such as:

user.to_json(:include => :settings)
user.to_json(:include => { :settings => :all })

These methods do not seem to work, as the JSON hash will just contain "settings": null. Is there any way to accomplish this? I am on version 1.2.0 which I understand is old.

settings.all should include defaults

I'm using this on a User model w/ has_settings. I would expect settings.all to include any defaults as well; e.g.

(As noted in other issue, would be nice to be able to specify model-specific defaults)
Settings.defaults[:foo] = "footastic"
u = User.find_first
u.settings.all

This should return {:foo => 'footastic'}

...

Just noticed pull request that has these features... #13

Incompatible with protected_attributes gem

Reproduced with Rails 4.2.1 and ledermann-rails-settings (2.3.0).

With the official protected_attributes gem (v 1.0.9) installed (and related usage of attr_accessible), the following error is logged:

WARNING: Can't mass-assign protected attributes for RailsSettings::SettingObject: var, target app/views/my_view.html.erb:48:in `block in ..._app_views_myview_html_erb___...'

This warning (as I'm sure you know) is commonly encountered with the protected_attributes gem when attempting to modify a resource property without defining that property to be attr_accessible. It's possible there's nothing we can do about it in this case, however I suspect that we could use feature detection in place of the Rails version comparison that happens in setting_object.rb on this line.

Perhaps mine is not a common use-case. The "best" solution is arguably to refactor and remove the protected_attributes gem and any reference to attr_accessible when using Rails 4 (this does indeed solve the problem, but is too great a refactor in our case).

How would I implement this on the form?

Say I have an User model with some settings. How would I implement so that settings can be updated on the User form?

An example would be much appreciated. Looked through test but didn't find any

Could not find generator rails_settings:migration

Hi

could use a hand getting up and running. Have installed the gem with bundle but cannot run the migration file. Then try to run

  rails g rails_settings:migration

but receive an error of

  Could not find generator rails_settings:migration

Running rails 3, Ruby 1.9.3, but I've also tried this in a rails 4 environment on my machine. I've tried creating the migration manually and running it, which works, but then if I add the code

  has_settings :dashboard, :calendar

to the Article model, and then fire up the server and console, If I try to examine the Article model, it reports

  NoMethodError: undefined method `has_settings' for #<Class:0x007fb4ab51ee08>

update gem please

Hey, it looks like your gem is a bit outdated and doesn't have support for caching, was scratching my head for a few minutes there!

Can't save settings for an instance.

Here is my class:

class User < ActiveRecord::Base
has_settings

self.settings.defaults[:subscription] = {}
end

Console:

1.9.3p194 :002 > u.settings.all
Settings Load (1.2ms) SELECT var, value FROM "settings" WHERE (("settings"."target_type" = 'User' AND "settings"."target_id" = 3))
=> {"subscription"=>{}}

1.9.3p194 :004 > u.settings.merge! :subscription, system_news: "1", system_messages: "0", support_messages: "1", newsletter: "0"
Settings Load (0.7ms) SELECT "settings".* FROM "settings" WHERE "settings"."var" = 'subscription' AND (("settings"."target_type" = 'User' AND "settings"."target_id" = 3)) LIMIT 1
Settings Load (0.4ms) SELECT "settings".* FROM "settings" WHERE "settings"."var" = 'subscription' AND (("settings"."target_type" = 'User' AND "settings"."target_id" IS NULL)) LIMIT 1
Settings Load (0.6ms) SELECT "settings".* FROM "settings" WHERE "settings"."var" = 'subscription' AND (("settings"."target_type" = 'User' AND "settings"."target_id" IS NULL)) LIMIT 1
(0.2ms) BEGIN
(0.4ms) UPDATE "settings" SET "value" = '--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
system_news: ''1''
system_messages: ''0''
support_messages: ''1''
newsletter: ''0''
', "updated_at" = '2012-11-09 17:48:59.217941' WHERE "settings"."id" = 19
(12.7ms) COMMIT
=> {"system_news"=>"1", "system_messages"=>"0", "support_messages"=>"1", "newsletter"=>"0"}
1.9.3p194 :005 > u.settings.all
Settings Load (0.5ms) SELECT var, value FROM "settings" WHERE (("settings"."target_type" = 'User' AND "settings"."target_id" = 3))
=> {"subscription"=>{}}

So it's saving globally, with target_type = User but target_id = nil!

But if I modify this new Settings record in my database (postgresql) that target_id = 3, then the gem will see this record and will update it successfully.

Default class setting updated instead of instance-specific setting.

Easier to demonstrate than explain:

user = User.first
user.settings.foo_counter # nil. No value yet
User.settings.foo_counter # 2.  Default of 2
user.settings.foo_counter = user.settings.foo_counter + 1 # Could also be written as user.settings.foo_count += 1
User.settings.foo_counter # 3
user.settings.foo_counter # 3, but only because of above default.  no record was created for this user's setting

So, the reason it never creates a default for the user, but instead only updates the User class default is that this is how the statement is evaluated:

user.settings.foo_counter=(user.settings.foo_counter + 1)

However, this does as expected:

incremented_value = user.settings.foo_counter + 1
user.settings.foo_counter = incremented_value
User.settings.foo_counter # 2
user.settings.foo_counter # 3

The bug arises because the following happens:

  1. Outermost user.settings gets properly scoped and ScopedSettings.target_id returns user_id. @target in the ScopedSettings refers to user instance.
  2. Then the inner user.settings is evaluated and also properly scoped. ScopedSettings.target_id returns user_id.
  3. No value exists for the user, so class default is retrieved (target_type.constantize.settings[var_name.to_s]). Now ScopedSettings.target_id is nil because @target refers to User class.
  4. Setter method is called (foo_counter=) but now because @target is changed so it updates the class default instead of the instance default.

Hope that makes sense. I'm not sure how to best solve it. It seems that maybe the ScopedSettings class should use instance methods instead of class methods. That would ensure you could have different versions of ScopedSettings in play at one time. I'll try and work up a patch to that effect.

Feature Request: Historic values

It would be nice if it some how would be possible to see old values for settings.

This is the primary reason for having things in files now. The configuration files (and the changes to it) is versioned in git, using comments to describe the reason for change.

Are there any plans to make this possible.

Settings not loading in Sidekiq jobs

I've configured the settings to load in an initializer:

eg: Settings.defaults['domain'] = 'dragonflylist.com'

The initializer file is called 01_settings.rb under /initializers.

However the settings return nil when running under a Sidekiq job. I've only tried with default jobs, but I'm about to convert them over to settings in the actual database to see if it still occurs.

Running the sidekiq job manually via the rails console does not cause any errors.

Could the settings gem somehow not be threadsafe? I didn't have a problem running the jobs under resque.

Getting complete set of settings to show up

Hi guys, I am wondering if there's a straightforward way to show the complete set of settings. I can't find a way. Specifically I am writing an API endpoint that returns all user's settings as JSON, but to do this I need to remember each setting's key

user.settings(:likes_notifications)
.
.
.
user.settings(:comments_notifications)

I am hoping to do something like (in rails)

render json: user.settings

Is there a proper way to do this?

NOT working with ruby 2.2.0

With latest gem 2.3.0, rails 4.1.8, ruby 2.2.0, I saw this errors:

rails g rails_settings:migration
Could not find generator rails_settings:migration

NoMethodError: undefined method `has_settings' for User (call 'User.connection' to establish a connection):Class

However, when I do rvm use 2.1.2 , everything works fine.

Global Settings

Hi,

Is there anyway you could show usage for global settings?

I don't want settings stored on the instance level but on some something like:

FooSettings.time_stamp = DateTime.now

I only ever want a single FooSettings instance.

Thanks!

Need some help getting it to work

I followed the installation instructions, did the migration, restarted server, but here's what I see when I try to get/set:

1.9.3p374 :126 > u.settings(:design).update_attributes! :font => 'IM Fell'
NoMethodError: undefined method `settings' for #<User...>

Here's my User model:

class User < ActiveRecord::Base    
  has_settings :design, :defaults => { :font => 'Open Sans' }
end

undefined methods when use has_settings

Just confirmed that the Gem is installed:

  • ledermann-rails-settings (2.3.0)
    settings method works in the console.
> u.settings (:plan_list)
# Settings::PlanList Load (0.4ms) 
# SELECT `settings`.* FROM `settings` WHERE `settings`.`target_id` = 1 AND `settings`.`target_type` = 'User'
=> #<Settings::PlanList id: nil, var: "plan_list", value: {}, target_id: 1, target_type: "User", created_at: nil, updated_at: nil>

has_settings doesn't work:

> u.has_settings
=> # NoMethodError: undefined method `has_settings' for #<User:0x0000000852fb90>

In the user model, used as following:

has_settings :plan_list, class_name: 'Settings::PlanList' do |s|
  s.key :plan_list, defaults: { columns: Settings::PlanList::DEFAULT_COLUMNS }
end

Any suggestions?

always return string value in a hash

Settings.example = { :id => 1, :authentication => :plain }
Settings.example[:id] => return '1'
Settings.example[:authentication] => return 'plain'

Addtional '\r' in array after save

the gem handles array in a strange way

current_westore.settings(:order).site_spots=["店内轮候区", "1518", "牡丹房"]
=> ["店内轮候区", "1518", "牡丹房"]
current_westore.settings(:order).save
=> true
current_westore.settings(:order).site_spots
=> ["店内轮候区\r", "1518\r", "牡丹房"]

Settings based on model attributes

Hey so i'm trying to use this gem in a way that may be valuable to add in the documentation but i can't quite get it working the way that I am looking for

I'm trying to give default keys based on a certain status of the user.

So instead of
has_settings do |s|
s.key :circuit, :defaults => { :circuit => "15"}
end

i would like it to be conditional based on the status of the users subscription model level. Right now i have something like this

has_settings :market_role

def market_role
if self.roles.first.name == 'silver'
has_settings.key :circuit, :defaults => {:circuit => '"15"}
else
has_settings.key :circuit, :defaults => {:circuit => '"16"}
end
end

Any ideas on how to best implement this?

Default not being used correctly

I'm getting a bit of a strange issue.

I have a setting :no_emails which has a default of false.

I have explicitly set :no_emails to true for one user (dan).

I have not set this setting for another user (carl).

I would expect carl to use the default value (false), but it returns true for carl.

Here's a console log:

irb(main):083:0> dan.settings.all
  Settings Load (1.8ms)  SELECT var, value FROM "settings" WHERE "settings"."target_type" = 'User' AND "settings"."target_id" = 1
=> {"no_emails"=>false, "email_notifications_friendship"=>true, "email_notifications_weekly"=>true, "email_notifications_new_community_idea"=>true, "email_notifications_messages"=>true, "email_notifications_other"=>true, "facebook_auto_post"=>false, "twitter_auto_post"=>false, "email_notifications"=>true, "facbeook_open_graph_answer_poll"=>true, "facebook_open_graph_content_view"=>true, "facebook_open_graph_enjoy"=>true, "facebook_open_graph_leave_thought"=>true}
irb(main):084:0> carl.settings.all
  Settings Load (3.3ms)  SELECT var, value FROM "settings" WHERE "settings"."target_type" = 'User' AND "settings"."target_id" = 6
=> {"no_emails"=>false, "email_notifications_friendship"=>true, "email_notifications_weekly"=>true, "email_notifications_new_community_idea"=>true, "email_notifications_messages"=>true, "email_notifications_other"=>true, "facebook_auto_post"=>false, "twitter_auto_post"=>false, "email_notifications"=>true, "facbeook_open_graph_answer_poll"=>true, "facebook_open_graph_content_view"=>true, "facebook_open_graph_enjoy"=>true, "facebook_open_graph_leave_thought"=>true}
irb(main):085:0> dan.settings.no_emails
  Settings Load (1.7ms)  SELECT "settings".* FROM "settings" WHERE "settings"."target_type" = 'User' AND "settings"."target_id" = 1 AND "settings"."var" = 'no_emails' LIMIT 1
=> false
irb(main):086:0> carl.settings.no_emails
  Settings Load (1.7ms)  SELECT "settings".* FROM "settings" WHERE "settings"."target_type" = 'User' AND "settings"."target_id" = 6 AND "settings"."var" = 'no_emails' LIMIT 1
  Settings Load (1.1ms)  SELECT "settings".* FROM "settings" WHERE "settings"."target_type" = 'User' AND "settings"."target_id" IS NULL AND "settings"."var" = 'no_emails' LIMIT 1
=> true

One thing that strikes me as odd is that second Load for the carl user. Why is it doing that?

Looking in my database, there is a record with :target_type=>'User', :target_id=>nil, :var=>'no_emails' which is set to true.

What is the record with target_id = NULL supposed to represent and how has it been created?

Settings.defaults[:no_emails]

...returns false, so the default is set correctly.

I tried creating a test to replicate the issue, but it works fine in the test.

How could I have got into this situation? Is this a bug, or something I have done wrong?

Problems deleting False/Nil values

I had some issues trying to use the .destroy method, and it seems the system baulks if the value is False or Nil:

Settings.testing = false
=> false
Settings.all
=> {"testing"=>false}
Settings.destroy :testing
Settings::SettingNotFound: Setting variable "testing" not found
from ./rails_settings/lib/settings.rb:38:in `destroy'
from (irb):56
Settings.testing = "false"
=> "false"
Settings.destroy :testing
=> true

Remove setting

Hi,

maybe easy question, but couldn't find anything in Readme or otherwise.
How can I remove a setting, not just blank it?

My situation is that in controller, while testing things out, i have set a setting for user, but i had a typo. Let's say i wanted to set setting for "message" but now i have "messahe" in DB. When i noticed my error and fixed the typo i now have message & messahe.

How can i get rid of the messahe?

Thanks!

Could not find generator 'rails_settings:migration'

rails g rails_settings:migration
Could not find generator 'rails_settings:migration'. Maybe you meant 'rspec:integration' or 'active_record:migration' or 'test_unit:integration'
Run `rails generate --help` for more options.

Using ledermann-rails-settings 2.4.0

Can't precompile assets?

Everything works great in development for me but when I try to rake precompile:assets to get ready for push to production I get:

rake aborted!
Could not find table 'settings'

The only thing I can find are suggestions to migrate the database, which I have done. Any thoughts?

Better check for mass assignment?

We're using rails 4, but we're using the protected_attributes gem to handle the upgrade.

I currently get an error:

ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes for RailsSettings::SettingObject: var, target

Not sure how to fix. Tried some stuff but it didn't work. If you tell me where to go to fix, I can try to fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.