Giter VIP home page Giter VIP logo

Comments (14)

petehamilton avatar petehamilton commented on June 26, 2024

Hi,

There isn't currently a forum but maybe I should make one, At the moment it is really just me developing this and and so I don't know what the participation would be like? The github issues is just an easier way to manage problems for me right now.
Can you please post your models and migrations code please? It looks like you are right and it is mixing up the tables and their columns but I need to be able to replicate. Anonymise any confidential or private code information or variables.

from citier.

 avatar commented on June 26, 2024

Of course!

#Models
##################
class User < ActiveRecord::Base
  acts_as_citier

  attr_accessible :email, :password, :password_confirmation, :about, :activate_token, :created_at, :password_hash, :password_salt, :updated_at

  attr_accessor :password

  def self.authenticate(email, password)
    user = find_by_email(email)
   if user && BCrypt::Password.new(user.password_hash) == password
      user
    else
      nil
    end
  end
end
##################
class Patient < User
  acts_as_citier
end
##################

#Migrations
##################
class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string :type
      t.string :email
      t.string :password_hash
      t.string :password_salt
      t.boolean :activated
      t.string :activate_token

      t.timestamps
    end
  end

  def self.down
    drop_table :users
  end
end
##################
class CreatePatients < ActiveRecord::Migration
  def self.up
    create_table :patients do |t|
      t.boolean :is_checked_in
      t.datetime :check_in_time
      t.datetime :check_out_time

      #t.timestamps
    end
    create_citier_view(Patient)
  end

  def self.down
    drop_citier_view(Patient)
    drop_table :patients
  end
end
##################

from citier.

 avatar commented on June 26, 2024

I've pinpointed this down to the attr functions in the model, it now generates the same issues in both mysql2 and sqlite3:

p.save!
ActiveRecord::StatementInvalid: Mysql2::Error: Can not modify more than one base table through a join view 'development.view_patients': INSERT INTO view_patients (type, email, password_hash, password_salt, activated, activate_token, name, avatar, dob, about, created_at, updated_at, is_checked_in, check_in_time, check_out_time, hospital_id, condition_id, blog_id) VALUES ('Patient', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2011-05-21 18:29:22', '2011-05-21 18:29:22', NULL, NULL, NULL, NULL, NULL, NULL)

I don't know anything about view tables, so I'm lost.

from citier.

petehamilton avatar petehamilton commented on June 26, 2024

Hi,

What is the code you run before? To set up and save the model?

Also which versions of Ruby & Rails are you running? About to have a look at this in depth.

from citier.

petehamilton avatar petehamilton commented on June 26, 2024

Ok, so it appears this is because I have implemented 'save' but not 'save!'
I need to add it, if you run mypatient.save it should work fine
And also mypatient.valid? also works as does mypatient.errors

It's only when you do mypatient.save!

from citier.

petehamilton avatar petehamilton commented on June 26, 2024

Have done a simple fix which does a vlidation check and if that succeeds it continues to save correctly, otherwise it throws an RecordInvalid exception. Update to v0.1.12

from citier.

 avatar commented on June 26, 2024

Hmm, some strange stuff is still afoot with patient.save. The company repo is private but I threw what I've got up right now into my dropbox at http://dl.dropbox.com/u/24677548/Heartwaves.zip. Bout to hit up lunch.

from citier.

petehamilton avatar petehamilton commented on June 26, 2024

What code are you running? As in what are you trying to actually save? Just an empty object?

from citier.

 avatar commented on June 26, 2024

Both null and full.

from citier.

petehamilton avatar petehamilton commented on June 26, 2024

Hmmm I can't replicate, I just get this:

ruby-1.9.2-p180 :001 > u = Patient.new(:email=>"[email protected]")
citier -> Root Class
citier -> table_name -> users
citier -> Non Root Class
citier -> table_name -> patients
citier -> tablename (view) -> view_patients
 => #<Patient id: nil, type: "Patient", email: "[email protected]", password_hash: nil, password_salt: nil, activated: nil, activate_token: nil, created_at: nil, updated_at: nil, is_checked
_in: nil, check_in_time: nil, check_out_time: nil> 
ruby-1.9.2-p180 :002 > u.save!
citier -> Attributes for Patient: {"check_in_time"=>nil, "check_out_time"=>nil, "is_checked_in"=>nil}
citier -> UPDATE users SET type = 'User' WHERE id = 4
citier -> SQL : UPDATE users SET type = 'Patient' WHERE id = 4
 => true 

from citier.

 avatar commented on June 26, 2024

No, it works now--sshing into my server over lunch was misleading. Thank you for developing this awesome and powerful plugin, and for being so responsive!

from citier.

petehamilton avatar petehamilton commented on June 26, 2024

No worries! Keep me updated on any other issues, I am about to start two large projects and this will be a core component so there will no doubt be a lot more development over the next few days/weeks

from citier.

mbessieres avatar mbessieres commented on June 26, 2024

I'm still getting this error and I'm really not sure why. I've done all of your standard setup, but when I do save or save! it still causes:

Can not modify more than one base table through a join view

I'm on the latest rails, cities, mysql2

from citier.

mbessieres avatar mbessieres commented on June 26, 2024

And I'll add that in postgre it complains as well:

ERROR: cannot update a view HINT: You need an unconditional ON UPDATE DO INSTEAD rule. : UPDATE "view_writing_assignments" SET "id" = 12, "heading" = 'This is a new writing assignment', "type" = 'WritingAssignment', "prompt" = 'Will it work? please please please?' WHERE "view_writing_assignments"."type" IN ('WritingAssignment') AND "view_writing_assignments"."id" = 12

from citier.

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.