Wednesday 15 July 2015

How to create an empty activerecord object in rails 4? -



How to create an empty activerecord object in rails 4? -

i trying develop rails application quickbase there no adapter. checked online quickbase adapter not working old version of rails , author told me no longer supports it.

i want able utilize active record , associated concepts of typical rails application, intervene , modify how create, update , show actions work. have created application create new record successfully. however, when want able edit record, have first modified edit action go own database , info active record object.

to create empty active record said $user = user.new populated attributes info custom database. form still shows create user button, instead of update user button. apparently, guess because persist? method returning false "new" object. know not new one. how influence @user object think persistent one?

alternatively, there way can create blank @user object without new function?

i have checked on place, couldn't find clue on how accomplish this. give thanks much help.

you can seek calling @user.disconnect! after phone call @user = user.new, maintain activerecord trying write database, i'm not sure solve problem.

the larger problem you're trying fit square peg round hole here. entire point of activerecord abstract connection database. without database, what's point?

i think best solution write own qb adapter. may not hard think, since seem know how read/write database.

you can read more how here: http://api.rubyonrails.org/classes/activerecord/connectionadapters/abstractadapter.html

activerecord ruby-on-rails-4 quickbase

No comments:

Post a Comment