I'm trying to use the Ahoy gem to track user behaviour in an Ember CLI app with a Rails 4.2 backend. I am using the Rails gem (http://ift.tt/1euzW8q) and an Ember Add-on (http://ift.tt/1GPYoiE). I am using a MySQL database. This is proving quite difficult.
The problems I have encountered so far:
- The gem relies on UUIDs and the activeuuid gem, which do not seem to work properly. On attempting to save a model I receive the error "Mysql::Error: Data too long for column 'id' at row 1"). I think this is because the Ahoy gem migrations define binary(16) table entries in my database, and UUIDs are 36 characters; they are not being correctly converted to binary. I can solve this by replacing the binary(16) column with a binary(36) column - not the best solution but it works.
- Ahoy-Visit and Ahoy-Visitor data need to be included in all server request headers from my Ember app.
The problem now is that whenever I attempt to save a visit or event object (as defined by Ahoy) I receive an error:
ActiveModel::MissingAttributeError (can't write unknown attribute ``)
Full trace below. I am quite confused by this. Visit and event objects are created as expected, but if I open the console, load any object, change something and try to save it then I get this error. It occurs when any parameter is changed. In particular this is preventing me from assigning a user ID to visit objects created by Ahoy.
Any ideas on how to solve this? I wonder if it is related to the activeuuid gem, but am not sure how to go about finding the specific problem.
Many thanks.
2.0.0-p195 :001 > v = Visit.first
Visit Load (1.4ms) SELECT `visits`.* FROM `visits` LIMIT 1
=> #<Visit id: nil, visitor_id: "f0ba38d1-5130-4314-b63c-19bd1f74e5a2", ip: "127.0.0.1", user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) Ap...", referrer: nil, landing_page: "http://localhost:4200/", user_id: nil, referring_domain: nil, search_keyword: nil, browser: "Chrome", os: "Mac OS X", device_type: "Desktop", screen_height: 900, screen_width: 1440, country: "Reserved", region: nil, city: nil, postal_code: nil, latitude: 0, longitude: 0, utm_source: nil, utm_medium: nil, utm_term: nil, utm_content: nil, utm_campaign: nil, started_at: "2015-06-17 22:12:33">
2.0.0-p195 :002 > v.user_id = 1
=> 1
2.0.0-p195 :003 > v.save
SQL (0.2ms) BEGIN
(0.1ms) ROLLBACK
ActiveModel::MissingAttributeError: can't write unknown attribute ``
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/attribute.rb:124:in `with_value_from_database'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/attribute_set.rb:39:in `write_from_user'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/attribute_methods/write.rb:74:in `write_attribute_with_type_cast'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/attribute_methods/write.rb:56:in `write_attribute'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/attribute_methods/dirty.rb:92:in `write_attribute'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/transactions.rb:393:in `restore_transaction_record_state'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/transactions.rb:324:in `rolledback!'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:73:in `rollback_records'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:151:in `rollback'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:183:in `rollback_transaction'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:190:in `rescue in within_new_transaction'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/transaction.rb:205:in `within_new_transaction'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/transactions.rb:220:in `transaction'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/transactions.rb:344:in `with_transaction_returning_status'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activerecord-4.2.0/lib/active_record/transactions.rb:286:in `block in save'
... 4 levels...
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /Users/adam/Documents/Code/RailsApps/mercury/mercury-api/bin/rails:8:in `<top (required)>'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/adam/.rvm/gems/ruby-2.0.0-p195@mercury-web/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /Users/adam/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/adam/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
Aucun commentaire:
Enregistrer un commentaire