Giter Club home page Giter Club logo

settler's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

settler's Issues

uninitialized constant ApplicationController::Settler in Production environment

I don't know way on production environment the gem is not initialized correctly.

Gems

Rails 3.0.12
Settler 1.2.3

Error:

Completed 500 Internal Server Error in 207ms

ActionView::Template::Error (uninitialized constant ApplicationController::Settler):
    79:             .text-newsletter
    80:               Seguinos en:
    81:           .social-links
    82:             = link_to image_tag("facebook.png"), "http://www.facebook.com/#{facebook_user}"
    83:           .social-links
    84:             = link_to image_tag("twitter.png"), "http://www.twitter.com/#{twitter_user}"
    85: 
  app/controllers/application_controller.rb:51:in `facebook_user'
  app/views/layouts/application.html.haml:82:in `_app_views_layouts_application_html_haml___672982_70267324214000_0'

Application controller.

  helper_method :twitter_user, :facebook_user

  def twitter_user
    @twitter_user ||= Settler.twitter_user.value
  end

  def facebook_user
    @facebook_user ||= Settler.facebook_user.value
  end

Rails 3.2.17; Error: Can't mass-assign protected attributes: key

SOLUTION:

# in config/initializers/settler.rb

class Setting < ActiveRecord::Base
  attr_accessible *column_names
end

Settler.load!

SOURCES:


BACKGROUND:

irb(main):011:0> Setting.count
   (0.3ms)  SELECT COUNT(*) FROM "settings" WHERE (deleted = 'f' or deleted IS NULL)
=> 0
irb(main):012:0> Settler.load!
  Setting Load (0.1ms)  SELECT "settings".* FROM "settings" WHERE "settings"."key" = 'ask_mailer' LIMIT 1
ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: key
    from /Users/dev/.gem/ruby/2.1.8/gems/activemodel-3.2.17/lib/active_model/mass_assignment_security/sanitizer.rb:48:in `process_removed_attributes'
    from /Users/dev/.gem/ruby/2.1.8/gems/activemodel-3.2.17/lib/active_model/mass_assignment_security/sanitizer.rb:20:in `debug_protected_attribute_removal'
    from /Users/dev/.gem/ruby/2.1.8/gems/activemodel-3.2.17/lib/active_model/mass_assignment_security/sanitizer.rb:12:in `sanitize'
    from /Users/dev/.gem/ruby/2.1.8/gems/activemodel-3.2.17/lib/active_model/mass_assignment_security.rb:230:in `sanitize_for_mass_assignment'
    from /Users/dev/.gem/ruby/2.1.8/gems/activerecord-3.2.17/lib/active_record/attribute_assignment.rb:75:in `assign_attributes'
    from /Users/dev/.gem/ruby/2.1.8/gems/activerecord-3.2.17/lib/active_record/base.rb:498:in `initialize'
    from /Users/dev/.gem/ruby/2.1.8/gems/activerecord-3.2.17/lib/active_record/persistence.rb:44:in `new'
    from /Users/dev/.gem/ruby/2.1.8/gems/activerecord-3.2.17/lib/active_record/persistence.rb:44:in `create'
    from /Users/dev/.gem/ruby/2.1.8/gems/settler-2.0.1/lib/settler.rb:23:in `block (2 levels) in load!'
    from /Users/dev/.gem/ruby/2.1.8/gems/settler-2.0.1/lib/settler.rb:22:in `each'
    from /Users/dev/.gem/ruby/2.1.8/gems/settler-2.0.1/lib/settler.rb:22:in `block in load!'
    from /Users/dev/.gem/ruby/2.1.8/gems/activerecord-3.2.17/lib/active_record/scoping/default.rb:41:in `block in unscoped'
    from /Users/dev/.gem/ruby/2.1.8/gems/activerecord-3.2.17/lib/active_record/relation.rb:241:in `block in scoping'
    from /Users/dev/.gem/ruby/2.1.8/gems/activerecord-3.2.17/lib/active_record/scoping.rb:98:in `with_scope'
    from /Users/dev/.gem/ruby/2.1.8/gems/activerecord-3.2.17/lib/active_record/relation.rb:241:in `scoping'
    from /Users/dev/.gem/ruby/2.1.8/gems/activerecord-3.2.17/lib/active_record/scoping/default.rb:41:in `unscoped'
    from /Users/dev/.gem/ruby/2.1.8/gems/settler-2.0.1/lib/settler.rb:21:in `load!'
    from (irb):12
    from /Users/dev/.gem/ruby/2.1.8/gems/railties-3.2.17/lib/rails/commands/console.rb:47:in `start'
    from /Users/dev/.gem/ruby/2.1.8/gems/railties-3.2.17/lib/rails/commands/console.rb:8:in `start'
    from /Users/dev/.gem/ruby/2.1.8/gems/railties-3.2.17/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'irb(main):013:0> 

Settler 1.2.1 does not work with rails 3.1.0.rc4

settler 1.2.1 does not work with rails 3.1.0.rc4. As soons as settler is listed in the Gemfile the server does not start giving the following errors:

jakob@halo:~/projekte/aktiv/maintenancetool$ rails s
/home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_pool.rb:388:in retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished) from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_specification.rb:107:inretrieve_connection'
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in connection' from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activerecord-3.1.0.rc4/lib/active_record/attribute_methods/primary_key.rb:42:inget_primary_key'
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activerecord-3.1.0.rc4/lib/active_record/attribute_methods/primary_key.rb:26:in reset_primary_key' from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activerecord-3.1.0.rc4/lib/active_record/attribute_methods/primary_key.rb:17:inprimary_key'
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activerecord-3.1.0.rc4/lib/active_record/base.rb:1918:in attributes_protected_by_default' from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activemodel-3.1.0.rc4/lib/active_model/mass_assignment_security.rb:184:inprotected_attributes_configs'
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activemodel-3.1.0.rc4/lib/active_model/mass_assignment_security.rb:98:in attr_protected' from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/settler-1.2.1/lib/setting.rb:10 from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:inrequire'
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in require' from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:inload_dependency'
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:639:in new_constants_in' from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:223:inload_dependency'
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/activesupport-3.1.0.rc4/lib/active_support/dependencies.rb:237:in require' from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/settler-1.2.1/lib/settler.rb:4 from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:inrequire'
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in require' from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:ineach'
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in require' from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:ineach'
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in require' from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/bundler-1.0.15/lib/bundler.rb:120:inrequire'
from /home/jakob/projekte/aktiv/maintenancetool/config/application.rb:7
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/railties-3.1.0.rc4/lib/rails/commands.rb:52:in require' from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/railties-3.1.0.rc4/lib/rails/commands.rb:52 from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:intap'
from /home/jakob/.rvm/gems/ruby-1.8.7-p334@maintenancetool31/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49
from script/rails:6:in `require'
from script/rails:6

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.