Closed patrickmcelwee closed 12 years ago
Hi sorry for the delay, I just got back from vacation :)
This is a strange bug as wholesalers should have a created at field... Have you tried running the upgrade generator? rails g spree_wholesale:upgrade
then run rake db:migrate
This generator should reset the wholesalers' created at fields...
I'm a big fan of vacations :-)
I think you are right: that I had never run that. But, when I ran the migration, I got the error:
Mysql2::Error: Can't DROP 'created_at'; check that column/key exists: ALTER
TABLE wholesalers
DROP created_at
I am wondering whether there is an error in the UpgradeSpreeWholesale migration - or maybe it is just an error for me since I am inexplicably missing those db columns - but I wanted to check with you in case I am missing something:
def self.up remove_column :wholesalers, :created_at # I THINK I SHOULD DELETE THIS LINE remove_column :wholesalers, :updated_at # AND THIS ONE add_column :wholesalers, :created_at, :datetime add_column :wholesalers, :updated_at, :datetime Wholesaler.all.each do |wholesaler| wholesaler.created_at = wholesaler.user.created_at wholesaler.save end end
def self.down remove_column :wholesalers, :created_at remove_column :wholesalers, :updated_at end
Thanks,
Patrick
On Thu, Feb 9, 2012 at 11:44 AM, Spencer Steffen < reply@reply.github.com
wrote:
Hi sorry for the delay, I just got back from vacation :)
This is a strange bug as wholesalers should have a created at field... Have you tried running the upgrade generator?
rails g spree_wholesale:upgrade
This generator should reset the wholesalers' created at fields...
Reply to this email directly or view it on GitHub: https://github.com/citrus/spree_wholesale/issues/12#issuecomment-3890732
Commenting out those two lines should allow you to add the created_at and updated_at columns... give it a try and let me know how it goes :)
OK ... I went ahead and commented out those lines and it seems to work without problems. Thanks for your help!
You're welcome! Glad it worked out for ya :)
Great extension! We're hoping to make good use of it. I am working with the 0.60.x branch.
When logged in as a wholesaler and going to "My Account," the extension throws the error: undefined method `created_at' for "#Wholesaler:0xb57f85a4":Wholesaler
This comes from line 4 of spree_wholesale-bab7a33485ad/app/views/hooks/_wholesale_customer.html.erb:
<h4 class="wholesale-customer-id"><%= t('wholesale_customer_since', { :time => @user.wholesaler.created_at }) %></h4>
To get around the issue, I am just replacing @user.wholesaler.created_at with @user.created_at
Is it normal that my Wholesaler objects do not include a "created_at" field?