Then commit all changes by running: git commit -m "Generate PagesController. If you don’t already know, when we generate a new application, a new local git repository is initialized.Īdd all current changes by running: git add -A I think it’s time to create our first commit. We can start introducing new things to our website. Now when we go to we should see something like this instead of the default Rails information page. When we open pages_controller.rb, we see this: class PagesController Home page But usually I like to define the home page inside the PagesController. Of course we could define home page in a different controller and in different ways. Open a file pages_controller.rb app/controllers/pages_controller.rb I use Sublime Text, but you can use whatever you want to. Now open the Collabfield project in a text editor. We are going to use this PagesController to manage our special and static pages. The output in the command prompt should look something like this: This rails generator should have created some files for us. ![]() Run this line in your command prompt to generate a new controller. If you are not familiar with Rails controllers, you should skim through the Action Controller to get an idea what the Rails controller is. In order to do that, generate a new controller called Pages. We’re going to switch this default page with our own home page. When we go to we see the Rails welcome page. Open a browser and go to If everything went well, you should see the Rails signature welcome page. Now we should be able to see what we got so far. Navigate to a newly created directory by running the command: cd collabfieldĪnd now we can run our app by entering: rails s Now we should’ve successfully generated a new application. By default Rails uses SQlite3, but since we want to use PostgreSQL as our database, we need to specify it by adding: -database=postgresql To generate a new app run this line: rails new collabfield -database=postgresqlĬollabfield, that’s how our applications is going to be called. ![]() Once you are familiar with PostgreSQL, navigate to a directory where you keep your projects and open a command line prompt. ![]() If you haven’t created any Rails apps with PostgreSQL yet, you may want to check this tutorial. It is a popular choice among Ruby On Rails community. We are going to use PostgreSQL as our database.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |