Giter Site home page Giter Site logo

softace / activerecord-tableless Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kennethkalmer/activerecord-tableless-models

113.0 113.0 41.0 109 KB

Bringing together the different tableless model implementations into a single gem/plugin

License: Other

Ruby 98.38% Gherkin 1.62%

activerecord-tableless's People

Contributors

brendon avatar davefp avatar david135 avatar grossadamm avatar jarl-dk avatar johanneswuerbach avatar kennethkalmer avatar kreintjes avatar skamithi avatar vic avatar wagenet 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

activerecord-tableless's Issues

Rails 4.1.6 and "NoMethodError (undefined method `[]' for nil:NilClass)"

After upgrading from Rails 3.2.x to 4.1.6 i am getting this error.
NoMethodError (undefined method []' for nil:NilClass)`

Using newest protected_attributes (1.0.8) on a tableless model with activerecord-tableless (1.3.4):

/gems/activerecord-4.1.6/lib/active_record/attribute_methods/read.rb:113:in `block in read_attribute'",
/gems/activerecord-4.1.6/lib/active_record/attribute_methods/read.rb:111:in `fetch'",
/gems/activerecord-4.1.6/lib/active_record/attribute_methods/read.rb:111:in `read_attribute'",
/gems/activerecord-4.1.6/lib/active_record/attribute_methods.rb:381:in `[]'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:86:in `block in add_constraints'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:69:in `each'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:69:in `each_with_index'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:69:in `add_constraints'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:18:in `scope'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:7:in `scope'",
/gems/activerecord-4.1.6/lib/active_record/associations/association.rb:97:in `association_scope'",
/gems/activerecord-4.1.6/lib/active_record/associations/association.rb:86:in `scope'",
/gems/activerecord-4.1.6/lib/active_record/associations/collection_association.rb:404:in `scope'",
/gems/activerecord-4.1.6/lib/active_record/associations/collection_association.rb:474:in `create_scope'",
/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/associations.rb:6:in `block in build_record'",
/gems/activerecord-4.1.6/lib/active_record/core.rb:200:in `initialize'",
/gems/activerecord-4.1.6/lib/active_record/inheritance.rb:30:in `new'",
/gems/activerecord-4.1.6/lib/active_record/inheritance.rb:30:in `new'",
/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/reflection.rb:5:in `build_association'",
/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/associations.rb:5:in `build_record'",
/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/associations.rb:19:in `build'",
/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/nested_attributes.rb:117:in `block in assign_nested_attributes_for_collection_association'",
/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/nested_attributes.rb:112:in `each'",
/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/nested_attributes.rb:112:in `assign_nested_attributes_for_collection_association'",
/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/nested_attributes.rb:37:in `cards_attributes='",
/gems/activerecord-4.1.6/lib/active_record/attribute_assignment.rb:45:in `public_send'",
/gems/activerecord-4.1.6/lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'",
/gems/activerecord-4.1.6/lib/active_record/attribute_assignment.rb:56:in `block in assign_nested_parameter_attributes'",
/gems/activerecord-4.1.6/lib/active_record/attribute_assignment.rb:56:in `each'",
/gems/activerecord-4.1.6/lib/active_record/attribute_assignment.rb:56:in `assign_nested_parameter_attributes'",
/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/attribute_assignment.rb:71:in `assign_attributes'",
/gems/protected_attributes-1.0.8/lib/active_record/mass_assignment_security/core.rb:8:in `init_attributes'",
/gems/activerecord-4.1.6/lib/active_record/core.rb:198:in `initialize'",
/gems/activerecord-4.1.6/lib/active_record/inheritance.rb:30:in `new'",
/gems/activerecord-4.1.6/lib/active_record/inheritance.rb:30:in `new'",

and the same now without protected_attributes, using strong_parameters:

/gems/activerecord-4.1.6/lib/active_record/attribute_methods/read.rb:113:in `block in read_attribute'",
/gems/activerecord-4.1.6/lib/active_record/attribute_methods/read.rb:111:in `fetch'",
/gems/activerecord-4.1.6/lib/active_record/attribute_methods/read.rb:111:in `read_attribute'",
/gems/activerecord-4.1.6/lib/active_record/attribute_methods.rb:381:in `[]'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:86:in `block in add_constraints'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:69:in `each'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:69:in `each_with_index'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:69:in `add_constraints'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:18:in `scope'",
/gems/activerecord-4.1.6/lib/active_record/associations/association_scope.rb:7:in `scope'",
/gems/activerecord-4.1.6/lib/active_record/associations/association.rb:97:in `association_scope'",
/gems/activerecord-4.1.6/lib/active_record/associations/association.rb:86:in `scope'",
/gems/activerecord-4.1.6/lib/active_record/associations/collection_association.rb:404:in `scope'",
/gems/activerecord-4.1.6/lib/active_record/associations/collection_association.rb:474:in `create_scope'",
/gems/activerecord-4.1.6/lib/active_record/associations/association.rb:168:in `initialize_attributes'",
/gems/activerecord-4.1.6/lib/active_record/associations/association.rb:248:in `block in build_record'",
/gems/activerecord-4.1.6/lib/active_record/core.rb:200:in `initialize'",
/gems/activerecord-4.1.6/lib/active_record/inheritance.rb:30:in `new'",
/gems/activerecord-4.1.6/lib/active_record/inheritance.rb:30:in `new'",
/gems/activerecord-4.1.6/lib/active_record/reflection.rb:239:in `build_association'",
/gems/activerecord-4.1.6/lib/active_record/associations/association.rb:247:in `build_record'",
/gems/activerecord-4.1.6/lib/active_record/associations/collection_association.rb:130:in `build'",
/gems/activerecord-4.1.6/lib/active_record/nested_attributes.rb:465:in `block in assign_nested_attributes_for_collection_association'",
/gems/activerecord-4.1.6/lib/active_record/nested_attributes.rb:460:in `each'",
/gems/activerecord-4.1.6/lib/active_record/nested_attributes.rb:460:in `assign_nested_attributes_for_collection_association'",
/gems/activerecord-4.1.6/lib/active_record/nested_attributes.rb:343:in `cards_attributes='",
/gems/activerecord-4.1.6/lib/active_record/attribute_assignment.rb:45:in `public_send'",
/gems/activerecord-4.1.6/lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'",
/gems/activerecord-4.1.6/lib/active_record/attribute_assignment.rb:56:in `block in assign_nested_parameter_attributes'",
/gems/activerecord-4.1.6/lib/active_record/attribute_assignment.rb:56:in `each'",
/gems/activerecord-4.1.6/lib/active_record/attribute_assignment.rb:56:in `assign_nested_parameter_attributes'",
/gems/activerecord-4.1.6/lib/active_record/attribute_assignment.rb:36:in `assign_attributes'",
/gems/activerecord-4.1.6/lib/active_record/core.rb:455:in `init_attributes'",
/gems/activerecord-4.1.6/lib/active_record/core.rb:198:in `initialize'",
/gems/activerecord-4.1.6/lib/active_record/inheritance.rb:30:in `new'",
/gems/activerecord-4.1.6/lib/active_record/inheritance.rb:30:in `new'",

Can anyone help me out? I dont want to drop activerecord-tableless!

It seems that protected_attributes had kind of a similar bug and got it fixed. See rails/rails#13246
I have posted my question there earlier, but now that i kicked out protected_attributes and the error comes still up i think it is more related to activerecord-tableless.

can't delete_all

Rails 4
class MailerForm has_many Recipient and accepts_nested_attributes_for :recipients

example:

form = MailerForm.new(some_recipients_data)
p form.recipients
>> [#<MailerForm::Recipient mailer_form_id: nil, email: "[email protected]">, #             
<MailerForm::Recipient mailer_form_id: nil, email: "[email protected]">]

form.recipients.where(:email => "[email protected]").delete_all
p form.recipients
# got this
>> [#<MailerForm::Recipient mailer_form_id: nil, email: "[email protected]">, #             
<MailerForm::Recipient mailer_form_id: nil, email: "[email protected]">]
# instead of
>> [ #<MailerForm::Recipient mailer_form_id: nil, email: "[email protected]">]

so how I can do destroy ?

PG::UndefinedObject: ERROR: type "string" does not exist

Newbie to Ruby on Rails + Heroku Deployment .. not sure if this is issue is related to Active record - tableless Gem or with Heroku deployment environment. Works fine in my local (as I am not using PG)
Heroku environment details

  • ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
  • Rails 4.2.3
  • pg (0.18.2)

and this is the model code

class Visitor < ActiveRecord::Base
    has_no_table
    column :email, :string
    validates_presence_of :email
    validates_format_of :email, :with => /\A[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}\z/i
    def subscribe
        mailchimp = Gibbon::API.new
        result = mailchimp.lists.subscribe({
            :id => ENV['MAILCHIMP_LIST_ID'],
            :email => {:email => self.email},
            :double_optin => false,
            :update_existing => true,
            :send_welcome => true
            })
        Rails.logger.info("Subscribed #{self.email} to MailChimp") if result
    end
end

below is the whole log dump

015-07-18T18:52:44.319347+00:00 app[web.1]:     from /app/config.ru:in `new'
2015-07-18T18:52:44.319350+00:00 app[web.1]:    from /app/config.ru:in `<main>'
2015-07-18T18:52:44.319353+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
2015-07-18T18:52:44.319357+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
2015-07-18T18:52:44.319360+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
2015-07-18T18:52:44.319363+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
2015-07-18T18:52:44.319366+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
2015-07-18T18:52:44.319369+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/server.rb:61:in `app'
2015-07-18T18:52:44.319372+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
2015-07-18T18:52:44.319376+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:272:in `start'
2015-07-18T18:52:44.319382+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/server.rb:80:in `start'
2015-07-18T18:52:44.319385+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:80:in `block in server'
2015-07-18T18:52:44.319389+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-07-18T18:52:44.319392+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-07-18T18:52:44.319396+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2015-07-18T18:52:44.319399+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands.rb:17:in `<top (required)>'
2015-07-18T18:52:44.319402+00:00 app[web.1]:    from bin/rails:8:in `require'
2015-07-18T18:52:44.319405+00:00 app[web.1]:    from bin/rails:8:in `<main>'
2015-07-18T18:52:45.246428+00:00 heroku[web.1]: Process exited with status 1
2015-07-18T18:52:45.262519+00:00 heroku[web.1]: State changed from starting to crashed
2015-07-18T18:52:45.263702+00:00 heroku[web.1]: State changed from crashed to starting
2015-07-18T18:52:49.560089+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 52931 -e production`
2015-07-18T18:52:55.289443+00:00 app[web.1]: => Booting Thin
2015-07-18T18:52:55.289470+00:00 app[web.1]: => Rails 4.2.3 application starting in production on http://0.0.0.0:52931
2015-07-18T18:52:55.289473+00:00 app[web.1]: => Run `rails server -h` for more startup options
2015-07-18T18:52:55.289474+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-07-18T18:52:55.289475+00:00 app[web.1]: PG::UndefinedObject: ERROR:  type "string" does not exist
2015-07-18T18:52:55.289477+00:00 app[web.1]: LINE 1: SELECT 'string'::regtype::oid
2015-07-18T18:52:55.289478+00:00 app[web.1]:                ^
2015-07-18T18:52:55.289480+00:00 app[web.1]: : SELECT 'string'::regtype::oid
2015-07-18T18:52:55.289533+00:00 app[web.1]: Exiting
2015-07-18T18:52:55.289602+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec': PG::UndefinedObject: ERROR:  type "string" does not exist (ActiveRecord::StatementInvalid)
2015-07-18T18:52:55.289604+00:00 app[web.1]: LINE 1: SELECT 'string'::regtype::oid
2015-07-18T18:52:55.289605+00:00 app[web.1]:                ^
2015-07-18T18:52:55.289609+00:00 app[web.1]: : SELECT 'string'::regtype::oid
2015-07-18T18:52:55.289611+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `block in execute'
2015-07-18T18:52:55.289613+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract_adapter.rb:473:in `block in log'
2015-07-18T18:52:55.289616+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
2015-07-18T18:52:55.289618+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract_adapter.rb:467:in `log'
2015-07-18T18:52:55.289621+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:154:in `execute'
2015-07-18T18:52:55.289625+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:393:in `lookup_cast_type'
2015-07-18T18:52:55.289631+00:00 app[web.1]:    from /app/app/models/contact.rb:4:in `<class:Contact>'
2015-07-18T18:52:55.289628+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/bundler/gems/activerecord-tableless-800393c52bd2/lib/activerecord-tableless.rb:93:in `column'
2015-07-18T18:52:55.289634+00:00 app[web.1]:    from /app/app/models/contact.rb:1:in `<top (required)>'
2015-07-18T18:52:55.289638+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
2015-07-18T18:52:55.289641+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
2015-07-18T18:52:55.289648+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
2015-07-18T18:52:55.289645+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
2015-07-18T18:52:55.289654+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:317:in `depend_on'
2015-07-18T18:52:55.289651+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:360:in `require_or_load'
2015-07-18T18:52:55.289657+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:233:in `require_dependency'
2015-07-18T18:52:55.289661+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
2015-07-18T18:52:55.289664+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/engine.rb:471:in `each'
2015-07-18T18:52:55.289675+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/engine.rb:469:in `eager_load!'
2015-07-18T18:52:55.289668+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/engine.rb:471:in `block in eager_load!'
2015-07-18T18:52:55.289683+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
2015-07-18T18:52:55.289679+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/application/finisher.rb:56:in `each'
2015-07-18T18:52:55.289686+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/initializable.rb:30:in `instance_exec'
2015-07-18T18:52:55.289671+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/engine.rb:469:in `each'
2015-07-18T18:52:55.289678+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/engine.rb:346:in `eager_load!'
2015-07-18T18:52:55.289696+00:00 app[web.1]:    from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
2015-07-18T18:52:55.289689+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/initializable.rb:30:in `run'
2015-07-18T18:52:55.289702+00:00 app[web.1]:    from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
2015-07-18T18:52:55.289692+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
2015-07-18T18:52:55.289706+00:00 app[web.1]:    from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
2015-07-18T18:52:55.289699+00:00 app[web.1]:    from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
2015-07-18T18:52:55.289721+00:00 app[web.1]:    from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
2015-07-18T18:52:55.289729+00:00 app[web.1]:    from /app/config/environment.rb:5:in `<top (required)>'
2015-07-18T18:52:55.289708+00:00 app[web.1]:    from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each'
2015-07-18T18:52:55.289723+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/initializable.rb:54:in `run_initializers'
2015-07-18T18:52:55.289732+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
2015-07-18T18:52:55.289711+00:00 app[web.1]:    from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `call'
2015-07-18T18:52:55.289714+00:00 app[web.1]:    from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
2015-07-18T18:52:55.289726+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/application.rb:352:in `initialize!'
2015-07-18T18:52:55.289718+00:00 app[web.1]:    from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
2015-07-18T18:52:55.289735+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
2015-07-18T18:52:55.289738+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
2015-07-18T18:52:55.289741+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
2015-07-18T18:52:55.289748+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
2015-07-18T18:52:55.289751+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
2015-07-18T18:52:55.289745+00:00 app[web.1]:    from /app/config.ru:3:in `block in <main>'
2015-07-18T18:52:55.289754+00:00 app[web.1]:    from /app/config.ru:in `new'
2015-07-18T18:52:55.289774+00:00 app[web.1]:    from /app/config.ru:in `<main>'
2015-07-18T18:52:55.289776+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
2015-07-18T18:52:55.289780+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
2015-07-18T18:52:55.289781+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
2015-07-18T18:52:55.289783+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
2015-07-18T18:52:55.289787+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
2015-07-18T18:52:55.289790+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/server.rb:61:in `app'
2015-07-18T18:52:55.289792+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
2015-07-18T18:52:55.289795+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:272:in `start'
2015-07-18T18:52:55.289798+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/server.rb:80:in `start'
2015-07-18T18:52:55.289801+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:80:in `block in server'
2015-07-18T18:52:55.289804+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-07-18T18:52:55.289808+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-07-18T18:52:55.289811+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2015-07-18T18:52:55.289814+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.3/lib/rails/commands.rb:17:in `<top (required)>'
2015-07-18T18:52:55.289817+00:00 app[web.1]:    from bin/rails:8:in `require'
2015-07-18T18:52:55.289820+00:00 app[web.1]:    from bin/rails:8:in `<main>'
2015-07-18T18:52:56.648562+00:00 heroku[web.1]: Process exited with status 1
2015-07-18T18:52:56.673206+00:00 heroku[web.1]: State changed from starting to crashed

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Missing support for non Rails apps.

I'm having a stab at getting activerecord-tableless integrated in a Padrino application and initially ran into this problem:

activerecord-tableless/lib/activerecord-tableless.rb:42:in `has_no_table': uninitialized constant ActiveRecord::Tableless::ActsMethods::Rails

After forking and changing in my local version Rails::VERSION::STRING to ActiveRecord::VERSION::STRING I was able to at least get my app started but now I have the following issue.

When I try and initialize a new object (currently just in a console using u = User.new) I am getting the following error:

ActiveRecord::ConnectionNotEstablished: ActiveRecord::ConnectionNotEstablished

My user model looks like this:

class User < ActiveRecord::Base

  has_no_table

  column :name, :string
  column :email, :string

end

I currently don't have any another ActiveRecord settings in my application, do you think I would as if I was using a database to get this to work?

Adding in save, update_attributes methods

First, thanks for the great gem; it saved me a ton of time in having to implement this myself. That said, it would be great to be able to use FactoryGirl and some of the other testing gems along with the tableless models for consistency in my test suite.

I was able to do this, but I had to add the following methods to my model to handle any save-related calls:

def save
  if self.valid?
    return true
  else
    return false
  end
end

def save!
  if self.valid?
    return self
  else
    raise StandardError, self.errors
  end
end

def reload
  return self
end

def update_attributes(attributes = {})
  if attributes
    attributes.each do |name, value|
      self.send("#{name}=", value)
      if self.valid?
        return true
      else
        return false
      end
    end
  end
end

Would there be anything wrong with adding those to the gem itself? I imagine that I'm not the only one who would benefit from having these methods implemented.

undefined method strip_attributes

Hi,
I'm creating a site that is to rely on an API instead of the current DB. I thought I might be able to save some time by using this GEM. However, I'm still obtaining the above error - I'm not sure if attr_accessible is supported.

here's the example code snippet:

class AbTemplate < ActiveRecord::Base
  has_no_table
  attr_accessible :AB_template, ...

and when the relevant page is loaded in the browser there is the error:

undefined method `strip_attributes' for AbTemplate(Table doesn't exist):Class

Any ideas?

Thanks very much,
Rene

How to use Associations

Hi,
I am trying to use associations with table-less models. I do not find how to use associations in github documentation nor I am able to find any tutorial regarding it.
Suppose, I am using belongs_to relationship(like User belongs_to a Category). How I am supposed to get Category.all or find a category object given a category_id. Do I need to override all these methods?
If you have any working example or documentation for the same, please share.
For details, here is the stackoverflow question regarding the same.

ActiveRecord::JDBCError: Table 'xxxxxx' doesn't exist: SHOW FIELDS FROM

Using tableless to create a model that searchs and union other models.

My tableless model works, but it keeps giving this message:
ActiveRecord::JDBCError: Table 'xxxxxx' doesn't exist: SHOW FIELDS FROM
I'm clueless!

My setup:
Gemfile:

gem 'rails', '3.2.8'
gem 'activerecord-jdbcmysql-adapter'
gem 'jruby-openssl'
group :assets do
gem 'sass-rails', '> 3.2.3'
gem 'coffee-rails', '
> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'i18n', '>= 0.6.1'
gem 'brdinheiro', '>=3.3.0'
gem 'brcpfcnpj', '>=3.3.0'
gem 'composite_primary_keys'
gem 'trinidad'
gem 'authlogic'
gem 'adauth'
gem 'delayed_job_active_record'
gem 'will_paginate'
gem "activerecord-tableless", "~> 1.0.1"

Model


class Vinc_mov_mix < ActiveRecord::Base
has_no_table
column :estab_id, :integer
column :vinc_id, :integer
column :caged_id, :integer
column :nome, :varchar
column :pis, :varchar

has_one :vinculo, :primary_key => :vinc_id, :foreign_key => :CN_NUMERO_SEQ
has_one :estab, :primary_key => :estab_id, :foreign_key => :CN_NUMERO_SEQ
has_one :caged_trab,:primary_key => :caged_id, :foreign_key => :id:
VINC_TABLE = '' + Vinculo.table_name + ''
CAGED_TABLE = '' + CagedTrab.table_name + ''
ESTAB_TABLE = '' + Estab.table_name + ''
PAGE_SIZE = 50

def self.search(estabs_ids, criterios={}, page=0) #page=offset

 estabs_ids = estabs_ids.to_a
 page -= 1; page = 0 if page < 0  

 clauses = where_clauses(criterios)

 if estabs_ids.present?
    clauses[:vincs_clauses]  = ["#{ESTAB_TABLE}.cn_numero_seq IN (#{estabs_ids.join(',')})"] + clauses[:vincs_clauses]
    clauses[:cageds_clauses] = ["#{ESTAB_TABLE}.cn_numero_seq IN (#{estabs_ids.join(',')})"] + clauses[:cageds_clauses]
 end

 self.find_by_sql(
     "SELECT #{ESTAB_TABLE}.cn_numero_seq as estab_id, #{VINC_TABLE}.cn_numero_seq as vinc_id,  null as caged_id, #{VINC_TABLE}.no_partic_rais as nome, #{VINC_TABLE}.co_pis as pis
     from #{ESTAB_TABLE}
     join #{VINC_TABLE}  on  #{ESTAB_TABLE}.co_cnpj_cei = #{VINC_TABLE}.co_cnpj_cei
     where #{clauses[:vincs_clauses].join(' AND ')}
     UNION ALL
     SELECT #{ESTAB_TABLE}.cn_numero_seq as estab_id, null as vinc_id, #{CAGED_TABLE}.id as caged_id,  #{CAGED_TABLE}.nomeTrab as nome, #{CAGED_TABLE}.pis as pis
     from #{ESTAB_TABLE}
     join #{CAGED_TABLE}  ON #{ESTAB_TABLE}.co_cnpj_cei = #{CAGED_TABLE}.identificadorEstab
     where #{clauses[:cageds_clauses].join(' AND ')}
     order by nome
     limit #{page * PAGE_SIZE}, #{PAGE_SIZE}"    #limit <offset> <count>
 )

end

Can't use #build method on class and association

As stated in the title, if I run MyModel.build(name: 'test') I get an error:

undefined method `build' for MyModel(Table doesn't exist):Class

My class is this:

require 'activerecord-tableless'

class MyModel < ActiveRecord::Base
  has_no_table

  # Stands for MenuID
  column :mid, :string

  def find_by_mid(identifier)
    MyModel.build(mid: identifier)
  end

end

Model is quite simple, I tested even with :database => :pretend_success but same error.

I'm on rails 4.0.2, I would like to help but I'm having a lot of troubles setting up the test suite for the gem :\

Does the gem supports initialization of tableless model instance through association?

Greetings.

Currently I'm trying to initialize object through has_one association like this:

class Report < ActiveRecord::Base
  has_no_table

  belongs_to :reportable, polymorphic: true

  column :reportable_id, :integer
  column :reportable_type, :string
  column :period, :daterange, 1.month.ago..Time.current

  attr_accessible :smth
end
class Store < ActiveRecord::Base
  has_one :report, as: :reportable

  # ...
end

But getting only:

> Store.take.build_report
  Store Load (0.6ms)  SELECT "stores".* FROM "stores" LIMIT 1
NoMethodError: undefined method `sanitize_limit' for #<Object:0x000001059b8ba0>
from /Users/jibiel/.rvm/gems/ruby-2.0.0-p451@smth/gems/activerecord-4.0.0/lib/active_record/relation/query_methods.rb:808:in `build_arel'

Is this currently supported? Could you please provide an example?

I suspect this is rather me not understanding things than lack of implementation.
Anyways, it'll be great to see such example in the README.md.

Thanks.

Seems to be not working on Rails 4.2.0.beta2

class Customer < ActiveRecord::Base

  has_no_table

  column :id, :integer

end

> Customer.new
(Object doesn't support #inspect)
=>

I'm using version 1.3.4 of this gem by the way. Thanks!!

accepts_nested_attributes_for doesn't seem to work

Hi,

I am running Rails 3.2.9 (the 3-2-stable branch on github) and have the gem working nicely on 2 of my models, Transmission and Recipient. I have Transmission set up with

accepts_nested_attributes_for :recipients

but when I try to save a Transmission with some nested attributes then it causes an error where it is trying to query the db for details on the recipients table.

Should accepts_nested_attributes work as normal or is it not supported with this gem?

Thanks for any help.

David

Information for those wanting to use without a Database

I think it may pay to include details about using this gem without a database.

Doing a rails install without Active Record - rails new example --skip-active-record

In config/application.rb

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"

Active Record is not required by bundler (because 'activerecord' is the gem and 'active_record' is the lib) it is normally done by the require 'active_record/railtie' (presumably by design) so to get activerecord-tableless working without a database you will need to require 'active_record' in config/application.rb

An example with nested attributes?

Hi, I am the author of the cocoon gem, and received a request to be able to create nested forms with ActiveModel models. This gems seems like the perfect answer from the short explanation in the readme, except I have no idea how you can implement two nested tableless models.

In the code I see no overruling of any association code (at first sight), so not sure it is actually supported at all. Also, while claims are made, I see no examples ;)

If you can provide me with a simple explanation, I am willing to play around myself, no need for big elaborate examples ;) If I can get it to work, I can update the README myself :)

Rails 3.2.13 problems with has_many_through relationships

In Rails 3.2.13 I'm experiencing problems when trying to use tableless models as
one side of a has_many_through relationship

  class List < ActiveRecord::Base
     # persisted model
     has_many :memberships
     has_many :items , :through => :memberships
   ...
  end

  class Item < ActiveRecord::Base
    has_no_table :database => :pretend_success

    has_many :memberships
    has_many :lists , :through => :memberships

    ...
  end

  class Mermbership < ActiveRecord::Base
    # persisted model / join model
    belongs_to :list
    belongs_to :item
  end

  l = List.first
  l.items
  (Object doesn't support #inspect)

 l.items.class
 NoMethodError: undefined method 'supports_explain?' for #<Object:...>

Return ActiveRecord::Relation from a tableless model

Hi,

In my application (Rails 4), the User model is not stored in the 'local' database but is on a backoffice application.

So, I use a tableless model and I have a module 'ApiUser' to access my backoffice.

The User model (tableless) use this module for every operation (read or write data...) on the backoffice.

Of course, I need every ActiveRecord methods, like new, save, update, destroy, all, find....

I'm not sure it's the good way, but in my model I implement a 'all' method (and a corresponding function in the API to retrieve data from the backoffice).
For the moment, in the model, I create an array populated with data by doing something like :

result = call_to_api_to_retrieve_datas
users = []
result[:user].each { |user| users << User.new(user) }
return users

It seems to work, but I have relation (has_many) to other models and some automatic functions don't work (each, index_by, map...) on the relation.

My question : is reimplementig each ActiveRecord method is the good way to do and how to simulate an ActiveRecord::Relation like a real ActiveRecord model ?

If you need more informations on my model, let me know.

Thanks

Rails 6 support

Hi I am facing an issue when I try to upgrade to rails 6.Is there any plan to support rails 6 version?

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.