Wednesday, February 4, 2015

Day 18

Posted by
Posted on
Posted under
Comments
Today was pretty full-on. We started off by installing Postgres, so I guess it’s goodbye to Sqlite3. Now I have 2 elephants on my toolbar. Having apps with a Postgres database means we can deploy them to Heroku.
We spent pretty much all day flexing our CRUD muscles again, but this time we introduced another model (for a grand total of 2) and some associations. The idea was that we were making a site for an art gallery that stored information about artists and their work. One artist could have many works, while a work belonged to a single artist. The main reason for the exercise was to get used to doing this in Rails as well as learning about new helpers along the way, such as the form helper. Another aspect was migrations and how you can rollback if you mess something up or make a type, and how you can add new columns to a table with a new migration. Using annotate also helps to check if the models are linked to the correct tables.
All in all this is what I have gathered so far when it comes to starting a new Rails project. This could be wrong/over-complicated in places, but I found it helped me out when it came to the assignment:
Feel free to correct me on that.
The assignment is to create a similar site but with books and authors, referencing the code for the above task as little as possible.
Topics covered:

Assignment:
I was happy that I managed to get some sort of grid working for the author and books index pages. The books on the individual author pages didn’t really want to cooperate, however.
Authors page.
The above screenshot shows the authors index page. I styled the site with Bootstrap and made these thumbnails, with a bit of info.
Below is the standard form for the site. The one for adding/editing an author is the same but with less fields. At the bottom there is a select menu to choose an author to associate the book with.
A form with Rails and Bootstrap.
Below is the page for a single author. It shows a picture, some info and then a grid of that author’s books. When a book is added a new line starts in the grid. The user has the option to edit or delete the author, with a warning from the browser before the latter is fully carried out.
Page for a single author.
Finally, this is the page for a single book. With less information I simply spread out the info box more.
More.. https://tomvalorsa.wordpress.com/2015/02/04/day-18/

Powered by: BKGjewelry