Giter VIP home page Giter VIP logo

Comments (13)

pokonski avatar pokonski commented on September 13, 2024

Hi! I will take a look at this today. Thank you for reporting!

from public_activity.

pokonski avatar pokonski commented on September 13, 2024

Tested this on the latest Rails 3.2.9 and there is no deprecation warning. Please update the Rails gem and report again.

from public_activity.

deanpcmad avatar deanpcmad commented on September 13, 2024

I'm using Rails 3.2.9 and public_activity 0.5.4 and I'm still getting the issue. I'm not too sure whether it is public_activity causing the problem. I've updated most of the gems and upgraded the public_activity database.

from public_activity.

farnoy avatar farnoy commented on September 13, 2024

Could you post the exact warning you get? I can only think of this line, but I'm not sure.

from public_activity.

deanpcmad avatar deanpcmad commented on September 13, 2024

Sure, the message I'm getting is:

DEPRECATION WARNING: You're trying to create an attribute `recipient_id'. Writing arbitrary attributes on a model is deprecated. Please just use `attr_writer` etc. (called from logged_in at /Users/deanperry/Projects/project/spec/spec_helper.rb:45)
DEPRECATION WARNING: You're trying to create an attribute `recipient_type'. Writing arbitrary attributes on a model is deprecated. Please just use `attr_writer` etc. (called from logged_in at /Users/deanperry/Projects/project/spec/spec_helper.rb:45)
      re-renders the :new template

It only seems to do it in the test environment though.

RAILS_ENV=test rails c
Loading test environment (Rails 3.2.9)
>> Customer.create! name: "hello again"
   (0.2ms)  BEGIN
  Customer Exists (0.4ms)  SELECT 1 AS one FROM `customers` WHERE `customers`.`uuid` = 'db0ba553-46d4-46f6-8fb7-158046ba89d8' ORDER BY id DESC LIMIT 1
  SQL (0.3ms)  INSERT INTO `customers` (`address1`, `address2`, `address3`, `business_name`, `created_at`, `email`, `mobile`, `name`, `phone`, `postcode`, `updated_at`, `uuid`, `where_find_us`) VALUES (NULL, NULL, NULL, NULL, '2012-12-29 11:34:07', NULL, NULL, 'hello again', NULL, NULL, '2012-12-29 11:34:07', 'db0ba553-46d4-46f6-8fb7-158046ba89d8', NULL)
DEPRECATION WARNING: You're trying to create an attribute `recipient_id'. Writing arbitrary attributes on a model is deprecated. Please just use `attr_writer` etc. (called from irb_binding at (irb):1)
DEPRECATION WARNING: You're trying to create an attribute `recipient_type'. Writing arbitrary attributes on a model is deprecated. Please just use `attr_writer` etc. (called from irb_binding at (irb):1)
  SQL (0.3ms)  INSERT INTO `activities` (`created_at`, `key`, `owner_id`, `owner_type`, `parameters`, `trackable_id`, `trackable_type`, `updated_at`) VALUES ('2012-12-29 11:34:08', 'customer.create', NULL, NULL, '--- {}\n', 7, 'Customer', '2012-12-29 11:34:08')
   (0.4ms)  UPDATE `activities` SET `updated_at` = '2012-12-29 11:34:08', `parameters` = '--- {}\n' WHERE `activities`.`id` = 52
   (0.5ms)  COMMIT
=> #<Customer id: 7, name: "hello again", business_name: nil, address1: nil, address2: nil, address3: nil, postcode: nil, phone: nil, mobile: nil, email: nil, uuid: "db0ba553-46d4-46f6-8fb7-158046ba89d8", created_at: "2012-12-29 11:34:07", updated_at: "2012-12-29 11:34:07", where_find_us: nil>

In the development console it works ok:

rails c
Loading development environment (Rails 3.2.9)
>> Customer.create! name: "hello again"
   (0.2ms)  BEGIN
  Customer Exists (0.4ms)  SELECT 1 AS one FROM `customers` WHERE `customers`.`uuid` = '07f6ede7-7864-42b4-9593-fbde11e09738' ORDER BY id DESC LIMIT 1
  SQL (0.3ms)  INSERT INTO `customers` (`address1`, `address2`, `address3`, `business_name`, `created_at`, `email`, `mobile`, `name`, `phone`, `postcode`, `updated_at`, `uuid`, `where_find_us`) VALUES (NULL, NULL, NULL, NULL, '2012-12-29 11:34:55', NULL, NULL, 'hello again', NULL, NULL, '2012-12-29 11:34:55', '07f6ede7-7864-42b4-9593-fbde11e09738', NULL)
  SQL (0.6ms)  INSERT INTO `activities` (`created_at`, `key`, `owner_id`, `owner_type`, `parameters`, `trackable_id`, `trackable_type`, `updated_at`) VALUES ('2012-12-29 11:34:55', 'customer.create', NULL, NULL, '--- {}\n', 1, 'Customer', '2012-12-29 11:34:55')
   (0.4ms)  UPDATE `activities` SET `updated_at` = '2012-12-29 11:34:55', `parameters` = '--- {}\n' WHERE `activities`.`id` = 3
   (0.5ms)  COMMIT
=> #<Customer id: 1, name: "hello again", business_name: nil, address1: nil, address2: nil, address3: nil, postcode: nil, phone: nil, mobile: nil, email: nil, uuid: "07f6ede7-7864-42b4-9593-fbde11e09738", created_at: "2012-12-29 11:34:55", updated_at: "2012-12-29 11:34:55", where_find_us: nil>

from public_activity.

farnoy avatar farnoy commented on September 13, 2024

And what do you have at /Users/deanperry/Projects/project/spec/spec_helper.rb:45?

from public_activity.

deanpcmad avatar deanpcmad commented on September 13, 2024

Line 45 of spec_helper.rb is User.create!(:username => "bob", :password => "password", :name => "Bob"). It's a method for creating and logging in a user because the whole app is protected.

from public_activity.

farnoy avatar farnoy commented on September 13, 2024

Are you sure you've executed the latest migration? This could be caused by a missing columns, which we use as foreign keys.

from public_activity.

deanpcmad avatar deanpcmad commented on September 13, 2024

I have yep. I've also completely reset the database and all that.
When running the public_activity update it doesn't seem to do much, is this right?

==  UpgradeActivities: migrating ==============================================
==  UpgradeActivities: migrated (0.0000s) =====================================

from public_activity.

farnoy avatar farnoy commented on September 13, 2024

It should. Could you post your schema.rb section for activities table?

from public_activity.

deanpcmad avatar deanpcmad commented on September 13, 2024

Sure, here it is:

create_table "activities", :force => true do |t|
    t.integer  "trackable_id"
    t.string   "trackable_type"
    t.integer  "owner_id"
    t.string   "owner_type"
    t.string   "key"
    t.text     "parameters"
    t.datetime "created_at",     :null => false
    t.datetime "updated_at",     :null => false
  end

I've deleted the db/schema.rb file and reset the database as well.

from public_activity.

farnoy avatar farnoy commented on September 13, 2024

You're missing recipient_id and recipient_type. If you're resetting the database anyway, replace the create_activities migration with the one form a newer p_a (one new line).

For some reason, UpgradeActivities makes no changes for you when it should.

from public_activity.

deanpcmad avatar deanpcmad commented on September 13, 2024

Excellent, I've removed the old create_activities migration and the upgrade_activities and I've copied the code from https://github.com/pokonski/public_activity/blob/master/lib/generators/public_activity/migration/templates/migration.rb and I'm not getting that error any more. Thanks for your help!

from public_activity.

Related Issues (20)

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.