Comments (14)
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.
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.
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 INTOview_patients
(type
,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.
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.
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.
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.
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.
What code are you running? As in what are you trying to actually save? Just an empty object?
from citier.
Both null and full.
from citier.
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.
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.
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.
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.
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)
- undefined method `create_view' HOT 4
- How to use the latest Citier code? HOT 6
- item.type is deprecated HOT 1
- superclass mismatch for class SQLiteAdapter HOT 4
- Getting citier to work with SQL server
- Citier will not allow a migration for me. HOT 4
- How to suppress the citier logging HOT 1
- Unable to call destroy on Citier subtype HOT 2
- :counter_cache => true support
- relation_methods.rb delete_all strange behavior HOT 2
- View_xxx does not exist | PostgreSQL HOT 2
- Docs need some updating
- Inserting a new inherited class in the middle
- stack level too deep (when changing model inheritance)
- Two level inheritance => fetch issue HOT 1
- update_all raises ActiveRecord::StatementInvalid
- rake db:setup fails on fresh database HOT 1
- Rspec tests failing - stack level too deep error
- STI class not inheriting attributes from citier child class HOT 6
- Two level inheritance, Child Class don't inherit Middle Class attributes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from citier.