Working on associations and ActiveRecord is actually pretty fun. Today was a lab day, so for the entire day I coded away on a Pokemon lab app and a Landlord app. I didn’t bother putting in too much extra work with the Pokemon one, but I had some fun with styling and creating more dynamic drop downs for the landlord one. The apps focused on searching records, the association between records, and being able to add, update, and delete records. Seeing CRUD in action made it make a lot more sense to me.
One cool thing I learned today? The dependent destroy association, where you can delete all records of a table that are related to the record of another table. It was definitely a very cool moment realizing there was a simple way to resolve an issue I had. The more I delve into this whole coding thing, the hungrier I get to learn more. I’m excited to see how much progress I make next week. I never thought I’d understand CRUD so well, and with every repetitive line of code I write for these assignments, the more it sinks in.
Next we reviewed CRUD with ActiveRecord and Sinatra. The instructor walked us through setting up basic adding, deleting, and editing items in a simple Sinatra app. Then we worked on tackling the same work-flow, and later the class broke to begin working on a CRUD lab as well as another CRUD-related homework assignment.
One thing I’m noticing is that this bootcamp definitely gives you your fair share of highs and lows. Sometimes there are highs when you’ve managed to solve a problem creatively. Other times there are lows when you haven’t been able to figure something out. I guess the moral of the story is to keep at it when you’re having a low, because soon enough you will get another high.
We covered a lot of ground with Sinatra that reminded me of rails back when I took the back-end web development course at GA, dealing with views and embedding Ruby code in html templates.
We reviewed REST, otherwise known as REpresentational State Transfer, which refers to the way browsers interact with servers. This includes the five main methods: GET, POST, PUT, PATCH, and DELETE. We also learned about how query parameters can be set up in web applications where you pass in dynamic params.
The rest of the day involved working with ActiveRecord and Sinatra. Overall, understanding the structure of prepping files in Sinatra will take a little bit of review for me. There are some strange conventions involved with naming files and requiring other files, that will only take a matter of time before they are second nature to me.
We played around with Sinatra, which is a framework for quickly creating web applications in Ruby. Other ways include Rails, Express/Node.js, and Django. We reviewed how to set up routing, which tells the application what the URLs should be for different pages. You can also pass variables into the URLs for more dynamic URLs.
There’s different ways of working with data on the server, which include:
- GET – for ‘getting’ info (no data is changed)
- POST – for ‘creating’ new data (usually by submitting a form)
- PUT – for ‘updating’ existing data (usually by submitting a form)
- DELETE – for ‘deleting’ data
To create views in Sinatra, you let it know which pages you want to route to with erb files, which are files that include a mixture of HTML and Ruby code. You even can share variables in different views.
Later in the day we met with Outcomes where we had someone come in to speak to us about networking on Linkedin. We also worked on our brand statements and then did an exercise where everyone went around the room and said what the good qualities were of our different classmates. Here’s what everyone had to say about me:
- good eye for design
- picks up things quickly
- understands development
- ahead of the game
- quick learner
- quickly dissect a problem
- a leader
The rest of the day we delved into Active Record which was actually a lot of fun, where we learned about object-relational mapping. We played around with making queries and setting up new databases. Setting up Active Record does involve a number of steps that are somewhat confusing like putting together the models and database connections. In general it was pretty interesting seeing how to set up database schemas and seeding the databases.
We used AR to perform CRUD actions that include create, new, save, all, find, find_by, where, update, and destroy. I learned about how to connect to the database with postresql in order to actually get the queries to work. And the instructors discussed how convention is more important than configuration, and the conventions are a bit odd, it will take some time to get used to which ones are singular, plural, snake case, and camel case. Here’s an overview of the conventions covered:
- Model file names are singular and snake case
- Model class names are singular and camel case
- Database schema is plural
Overview of the methods covered:
- Class methods include all, new, first, last, and find
- Instance methods include attr_accessors, destroy, save, and update
It’s been an exhausting week packed with tons of assignments, hands-on work, and lectures. Today we continued our work with Ruby, focussing on object-oriented programming. We learned about classes for making different instances, initializing arguments when a new instance is created, and methods.
Later in the afternoon we looked at inheritance and how we can set up classes that inherit methods of other classes. Everything made sense to me, but when it comes to tackling hands-on projects, sometimes I have trouble figuring out where to start. Since we’re covering so much information every day, it’s easy enough to stumble here and there.
Last night I only got about two or three hours of sleep because I was determined to figure out our homework assignment. However, I ended up giving up, and turned in an incomplete assignment. This morning I got to GA pretty early, and was still determined to figure it out. Eventually I did. The problem? I was having trouble wrapping my mind around mapping arrays in Ruby. Eventually I figured it out, and although the struggle took hours, finding a solution made me feel incredibly satisfied.
During the day we focused a large chunk of time on SQL and making database queries, what relationship databases are, and figuring out the relationships between different databases. I thought SQL queries were actually pretty fun.
In the afternoon we worked on a Ruby lab, which involved creating a command line game that quizzes the user on their knowledge of the state capitals. Surprisingly enough, it was a lot easier to put together. I suppose a night of struggling with the language really paid off in the end – I even played around with using a Ruby regular expression.
This course definitely has its fair share of highs and lows, but I’m excited to see how my skills shape up in the next few weeks.
Wow, right when you’re beginning to feel comfortable with one language, your world gets flipped upside-down. Today we started working with Ruby, and although I took General Assembly’s back-end web development class a few months ago, I realize I never really quite absorbed the information.
- for … in
- loop do
Afterwards, the class jumped on the homework assignments, and it was definitely a struggle. For the first time, it looks like I won’t be able to complete mine. However, I’m refusing to give up just yet. Hopefully I can make sense of this soon…
Today we worked on refactoring the code for our first project, or in other words, cleaning up the code. I found myself feeling a bit exhausted from working on the Flash Cards project, so I delved into my Hangman project a little bit and made quite a bit of progress. You can see my Hangman project here.
The biggest takeaway from our first project week is that it’s important to find something to work on that you can be passionate and excited about. Otherwise, it’s all too easy not to feel too dedicated about what you’re working on, which is something you never want to have happen.
In the morning we presented our projects in a science-fair style, where several of us had our laptops set up on boxes. I realized I was way more excited to talk to people about the logic behind my incomplete Hangman project than I was about the logic behind my Flash Cards. It just goes to show that it’s better to work on something that you can get excited about because you’ll work even more at getting it right.
After projects, it was a day focussed on object-oriented programming with constructor functions and prototypes. I’m realizing I’m understanding the concepts a lot better now, but certain concepts are still a bit of a struggle, like when to use return statements.
Nevertheless, I’m excited to see how things pan out with this program. Next week we start working with the back-end, so that shall be interesting.