Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
how to create a table using ActiveRecord alone
Li Chen
9/11/2008 3:08:00 PM
Hi all,
I know I can create a table by running MySql first. I search some
tutorials on google but they all talk about creating a table using
MySql-like database then use ActiveRecord to connect them. I wonder if
it is possible to create a table with ActiveRecord only.
Thanks,
Li
--
Posted via
http://www.ruby-...
.
2 Answers
Florian Gilcher
9/11/2008 3:23:00 PM
0
On Sep 11, 2008, at 5:07 PM, Li Chen wrote:
> Hi all,
>
> I know I can create a table by running MySql first. I search some
> tutorials on google but they all talk about creating a table using
> MySql-like database then use ActiveRecord to connect them. I wonder if
> it is possible to create a table with ActiveRecord only.
>
> Thanks,
>
> Li
> --
> Posted via
http://www.ruby-...
.
>
You could use migrations. But thats just another way of describing the
table.
If you want another approach (defining a model and then letting the
abstraction
layer create the required database), you could use datamapper
instead[1].
Then, you class will look like this:
1 class Post
2 include DataMapper::Resource
3 property :id, Integer, :serial => true
4 property :title, String
5 property :subtitle, String :lazy => [:show]
6 property :body, Text :lazy => [:show]
7 property :views, Integer, :lazy => [:show]
8 property :summary, Text
9 end
#and
Post.auto_migrate!
will create/migrate your table automatically.
Regards,
Florian
[1]:
http://www.data...
Li Chen
9/11/2008 5:57:00 PM
0
Florian Gilcher wrote:
> If you want another approach (defining a model and then letting the
> abstraction
> layer create the required database), you could use datamapper
> instead[1].
>
> Then, you class will look like this:
> [1]:
http://www.data...
I visit the wetsite:
http://www.data...
. It says it is not good
under window system. I wonder how good it is under Vista.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
how to create a table using ActiveRecord alone
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password