Rails ActiveRecord yog dab tsi?
Rails ActiveRecord yog dab tsi?

Video: Rails ActiveRecord yog dab tsi?

Video: Rails ActiveRecord yog dab tsi?
Video: Ruby on Rails by Leila Hofer 2024, Kaum ib hlis
Anonim

Rails Active Cov Ntaub Ntawv yog Object/Relational Mapping (ORM) txheej muab nrog Rails . Nws zoo ua raws li tus qauv ORM tus qauv, uas yog raws li hauv qab no - daim duab qhia chaw rau cov chav kawm, kab ntawv qhia rau cov khoom thiab. kem daim ntawv qhia rau khoom yam ntxwv.

Raws li txoj cai, Rails qauv yog dab tsi?

A Rails Model yog ib chav Ruby uas tuaj yeem ntxiv cov ntaub ntawv khaws cia (xav txog tag nrho cov kab hauv Excel lub rooj), nrhiav cov ntaub ntawv tshwj xeeb uas koj tab tom nrhiav, hloov kho cov ntaub ntawv, lossis tshem tawm cov ntaub ntawv. Cov kev ua haujlwm zoo li no raug xa mus los ntawm lub npe CRUD--Tsim, Tshem Tawm, Hloov Kho, Ua kom puas.

Tsis tas li ntawd, Rails ApplicationRecord yog dab tsi? Rails 5 tus Daim ntawv thov yog qhov chaw muab generic qauv logic. Txij li thaum Rails 5, domain qauv tau txais los ntawm Daim ntawv thov los ntawm lub neej ntawd. Qhov no yog qhov chaw tso cai uas yuav tsum muaj nyob rau hauv tag nrho koj daim ntawv thov tus qauv. Tsis muaj laj thawj rau liab-patch ActiveRecord :: Pib thaum ua raws li qhov kev coj ua.

Tom qab ntawd, lo lus nug yog, dab tsi yog ActiveRecord hauv Ruby ntawm Rails?

ActiveRecord yog ib lub pov haum uas yog ib feem ntawm Ruby on Rails . Nws yog ORM, piv txwv li lub tsev qiv ntawv uas qhia peb cov khoom rau cov rooj. Hauv lwm lo lus, nws yog Ruby lub tsev qiv ntawv uas tso cai rau peb siv Ruby cov chav kawm txhawm rau nkag mus rau peb cov ntaub ntawv khaws cia hauv RDBMS, zoo li MySQL lossis PostgreSQL.

Yuav ua li cas yog ib tug active cov ntaub ntawv ua hauj lwm?

Nws yeej txhais tau tias Active Cov Ntaub Ntawv siv cov ntaub ntawv uas tau muab khaws cia rau hauv lub rooj database siv kab thiab kab, uas yuav tsum tau hloov kho lossis rov qab los ntawm kev sau SQL nqe lus (yog tias koj siv SQL database), thiab nws cia koj cuam tshuam nrog cov ntaub ntawv zoo li nws yog ib txwm muaj. Ruby khoom.

Pom zoo: