## Hi ##
I have 6 simple and fundamental Problem in RoR migration and although I
googled it and read many article about it and research it for a week , I
didn't understand it. please help me for these problems :

----------

1 - When I create a model (for example "rails generate model
Football_League") , I see in db/migration a "create_football_leagues.rb"
. I want know what is the rules of RoR for changing the name that I gave
to my migration ? ( My migration's name was FootballLeague and ruby
cretaed "create_football_leagues.rb")


----------


2 - What is the rules of naming ruby for creating a class in that file ?
( Ruby created a "CreateFootballLeague" class in
"create_football_leagues.rb")


----------


3 - After I use rake db:migrate , although I had 3 migration, I just see
such a image in cmd : ( I attached this image )
and I didn't any migration for another 3 migrations whereas sometimes
ago when I run a migration with rake db:migrate, all my migrations are
migrated.


----------


4 - After I type rake db:migrate and after that Rake execute
"create_football_leagues.rb" I go to mysql and I saw a table with
"schema_migrations" name. and in that table there are some versions of
my migrations. now I want to know what is the application of such a
table ?


----------


5 - In http://guides.rubyonrails.org I read that if we want to change
the primary key of a table from default id to our own field we must use
:primary_key option but I didn't understand how can I use it .If someone
can give an example for this subject.


----------

6 - What is the difference between this 2 commands : 1 - "rails generate
migration footabll" 2 - rails generate model football. I knew that
with "rails generate model football" we must some extra file in
app/model but I don't understand function of those files.


My friend please help me to solve these fundamental problems . special
thanks .

Attachments:
http://www.ruby-forum.com/attachment/6895/1.JPG


--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Peter Vandenabeele at Jan 10, 2012 at 5:07 pm

    On Tue, Jan 10, 2012 at 5:41 PM, amir e. wrote:

    ## Hi ##
    I have 6 simple and fundamental Problem in RoR migration and although I
    googled it and read many article about it and research it for a week , I
    didn't understand it. please help me for these problems :

    ----------

    1 - When I create a model (for example "rails generate model
    Football_League") , I see in db/migration a "create_football_leagues.rb"
    . I want know what is the rules of RoR for changing the name that I gave
    to my migration ? ( My migration's name was FootballLeague and ruby
    cretaed "create_football_leagues.rb")


    ----------


    2 - What is the rules of naming ruby for creating a class in that file ?
    ( Ruby created a "CreateFootballLeague" class in
    "create_football_leagues.rb")


    ----------


    3 - After I use rake db:migrate , although I had 3 migration, I just see
    such a image in cmd : ( I attached this image )
    and I didn't any migration for another 3 migrations whereas sometimes
    ago when I run a migration with rake db:migrate, all my migrations are
    migrated.


    ----------


    4 - After I type rake db:migrate and after that Rake execute
    "create_football_leagues.rb" I go to mysql and I saw a table with
    "schema_migrations" name. and in that table there are some versions of
    my migrations. now I want to know what is the application of such a
    table ?


    ----------


    5 - In http://guides.rubyonrails.org I read that if we want to change
    the primary key of a table from default id to our own field we must use
    :primary_key option but I didn't understand how can I use it .If someone
    can give an example for this subject.


    ----------

    6 - What is the difference between this 2 commands : 1 - "rails generate
    migration footabll" 2 - rails generate model football. I knew that
    with "rails generate model football" we must some extra file in
    app/model but I don't understand function of those files.


    My friend please help me to solve these fundamental problems . special
    thanks .

    Attachments:
    http://www.ruby-forum.com/attachment/6895/1.JPG
    Study "Rails Guides" http://guides.rubyonrails.org/
    * Getting started
    * Migrations
    * check for "generators"
    * ...

    HTH,

    Peter

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Amir e. at Jan 10, 2012 at 5:22 pm

    Study "Rails Guides" http://guides.rubyonrails.org/
    * Getting started
    * Migrations
    * check for "generators"
    * ...

    HTH,

    Peter
    I study it , and if I didn't understand.

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Peter Vandenabeele at Jan 10, 2012 at 10:30 pm

    On Tue, Jan 10, 2012 at 6:21 PM, amir e. wrote:
    Study "Rails Guides" http://guides.rubyonrails.org/
    * Getting started
    * Migrations
    * check for "generators"
    * ...

    HTH,

    Peter
    I study it , and if I didn't understand.
    OK, great.

    A good way to get better responses on a mailing is to
    mention e.g. "what did you read", "what did you try",
    "what was the outcome", "why do you think that is not
    correct" etc.

    E.g. from this guide:

    http://catb.org/~esr/faqs/smart-questions.html

    "
    Before You Ask

    Before asking a technical question by e-mail, or in a newsgroup, or on a
    website chat board, do the following:

    Try to find an answer by searching the archives of the forum you plan to
    post to.

    Try to find an answer by searching the Web.

    Try to find an answer by reading the manual.

    Try to find an answer by reading a FAQ.

    Try to find an answer by inspection or experimentation.

    Try to find an answer by asking a skilled friend.

    If you're a programmer, try to find an answer by reading the source code.

    When you ask your question, display the fact that you have done these
    things first; this will help establish that you're not being a lazy sponge
    and wasting people's time. Better yet, display what you have learned from
    doing these things. We like answering questions for people who have
    demonstrated they can learn from the answers.
    "

    Hope This helps and welcome :-)

    Peter

    --
    Peter Vandenabeele
    http://twitter.com/peter_v
    http://rails.vandenabeele.com

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Jan 10, 2012 at 5:15 pm

    On 10 January 2012 16:41, amir e. wrote:
    ## Hi ##
    I have 6 simple and fundamental Problem in RoR migration and although I
    googled it and read many article about it and research it for a week , I
    didn't understand it. please help me for these problems  :
    Rather than answer the questions in detail I suggest that you work
    right through a good tutorial such as railstutorial.org, which is free
    to use online, then many such questions will be answered. Also look
    at the Rails Guides.
    Make sure that you have installed the version of rails that matches
    the tutorial you are using.

    I will say, though, do not change the primary key from id unless you
    absolutely must do this, to cope with a legacy database. Otherwise
    you will make life difficult.

    Colin
    ----------

    1 - When I create a model (for example "rails generate model
    Football_League") , I see in db/migration a "create_football_leagues.rb"
    . I want know what is the rules of RoR for changing the name that I gave
    to my migration ? ( My migration's name was FootballLeague and ruby
    cretaed "create_football_leagues.rb")


    ----------


    2 - What is the rules of naming ruby for creating a class in that file ?
    ( Ruby created a "CreateFootballLeague" class in
    "create_football_leagues.rb")


    ----------


    3 - After I use rake db:migrate , although I had 3 migration, I just see
    such a image in cmd : ( I attached this image )
    and I didn't any migration for another 3 migrations whereas sometimes
    ago when I run a migration with rake db:migrate, all my migrations are
    migrated.


    ----------


    4 - After I type rake db:migrate and after that Rake execute
    "create_football_leagues.rb" I go to mysql and I saw a table with
    "schema_migrations" name. and in that table there are some versions of
    my migrations. now I want to know what is the application of such a
    table ?


    ----------


    5 - In http://guides.rubyonrails.org I read that if we want to change
    the primary key of a table from default id to our own field we must use
    :primary_key option but I didn't understand how can I use it .If someone
    can give an example for this subject.


    ----------

    6 - What is the difference between this 2 commands : 1 - "rails generate
    migration footabll"   2 - rails generate model football. I knew that
    with "rails generate model football" we must some extra file in
    app/model  but I don't understand function of those files.


    My friend please help me to solve these fundamental problems . special
    thanks .

    Attachments:
    http://www.ruby-forum.com/attachment/6895/1.JPG


    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


    --
    gplus.to/clanlaw

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Norm Scherer at Jan 10, 2012 at 6:08 pm

    On 01/10/2012 09:41 AM, amir e. wrote:
    ## Hi ##
    I have 6 simple and fundamental Problem in RoR migration and although I
    googled it and read many article about it and research it for a week , I
    didn't understand it. please help me for these problems :

    ----------

    1 - When I create a model (for example "rails generate model
    Football_League") , I see in db/migration a "create_football_leagues.rb"
    . I want know what is the rules of RoR for changing the name that I gave
    to my migration ? ( My migration's name was FootballLeague and ruby
    cretaed "create_football_leagues.rb")
    The name of the migration is only of passing interest. What it is named
    has very little to do with what it does. The whole idea of the
    migrations is to create/delete database tables and indexes and to
    add/remove columns to existing tables and sometimes to insert small
    amounts of initial data into tables (not recommended). The important
    thing in the migrations is the names of the tables and the names of the
    columns. The name of the migration is just so you recall what that
    migration was all about.
    ----------


    2 - What is the rules of naming ruby for creating a class in that file ?
    ( Ruby created a "CreateFootballLeague" class in
    "create_football_leagues.rb")
    As in the migration name, the name of the class that is in that file is
    of little interest. It is only used when you run a migration and really
    has nothing to do with what the migration really does. The class is
    bound to the name of the file by some rules that are not really very
    interesting. Just go with it and don't worry about it.
    ----------


    3 - After I use rake db:migrate , although I had 3 migration, I just see
    such a image in cmd : ( I attached this image )
    and I didn't any migration for another 3 migrations whereas sometimes
    ago when I run a migration with rake db:migrate, all my migrations are
    migrated.


    ----------


    4 - After I type rake db:migrate and after that Rake execute
    "create_football_leagues.rb" I go to mysql and I saw a table with
    "schema_migrations" name. and in that table there are some versions of
    my migrations. now I want to know what is the application of such a
    table ?
    The schema_migrations table is used to keep track of which migrations
    have been run. In 3 above all of the previously defined migrations have
    run so the only one that will be run is the new one. If you change a
    migration file which has already been run it will not be rerun. Only
    the migrations on a whole are tracked. If you want to run all of the
    migrations you can just 'rake db:drop db:create db:migrate'. Of course
    you will loose any data that is in the database.
    ----------


    5 - In http://guides.rubyonrails.org I read that if we want to change
    the primary key of a table from default id to our own field we must use
    :primary_key option but I didn't understand how can I use it .If someone
    can give an example for this subject.

    Don't do it. Rails works best and most easily if you go with the flow.
    ----------

    6 - What is the difference between this 2 commands : 1 - "rails generate
    migration footabll" 2 - rails generate model football. I knew that
    with "rails generate model football" we must some extra file in
    app/model but I don't understand function of those files.
    You need to read the tutorials on models. The migration generates the
    database tables. The model files define relations among the different
    Active Record classes that are formed from those columns. At a minimum
    a model file is required for each table (that you want to use with
    Active Record). The file will look like:[code]class Column <
    ActiveRecord::Base
    end<[/code]The relations are descirbed in the model files.

    Norm
    My friend please help me to solve these fundamental problems . special
    thanks .

    Attachments:
    http://www.ruby-forum.com/attachment/6895/1.JPG
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 10, '12 at 4:41p
activeJan 10, '12 at 10:30p
posts6
users4
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase