Fixing the failures ...by editing our two models: /app/models/todo.rb # app/models/todo.rb class Todo < ApplicationRecord # model association has_many :items, dependent: :destroy # validations validates_presence_of :title, :created_by end app/models/item.rb class Item < ApplicationRecord belongs_to :todo # validation validates_presence_of :name end running bundle exec rspec again will result in 0 errors as expected: Finished in … Continue reading Build a TDD RESTful JSON TODO-List API (pt.2)
I've found this awesome Tutorial on how to create a API, that is also test driven. It's going to be a easy ToDo-List where users can menage their ToDo-Lists and ToDo-Items. Let's start: With Rails version 5, it's possible to do a API only application, which means: slim set of middlewear ApplicationController > Application::API … Continue reading Build a TDD RESTful JSON TODO-List API (pt.1)
I've watched a great video on Youtube about Testing, by the awesome Sandi Metz. I really like her style when shes holding speeches at Ruby Cons. I think the whole Testing thing is really important for every developer so I give it a try and summarize what she said. Testing Alot of programmers dont bother … Continue reading Rails Conf 2013: The Magic Tricks of Testing by Sandi Metz
What makes and API RESTful? each individual request should have no context of the requests that came before it each request that modifies the database should act on one and only one row of one and only one table.Requests that only fetch information should get zero or more rows from one table. The resource endpoints … Continue reading Building a RESTful API
Hey guys, it's been nearly a month since I've written my last post. I've been busy with university. I've finished my little project, a recreation of a basic forum. It has user authentication, the abilty to make post entries and also commenting is possible. In the beginning I had alot more ideas for my first … Continue reading RESTful API
Inheritance is basically one class that takes features from a parent class like: class Bear < Animals. so every thing I do in the instance of the Bear class, would also work as if they were done to an instance of Animals. It lets us do common functionalities in the Animals class and be more specific … Continue reading Learn Ruby the Hard Way: What is Inheritance?
Rules for If-statements mandatory else-statement if else-statment never runs, because it doesnt make sense, there need to be a die function, that prints out an error message and closes afterwards Don't nest if-statements more than 2 deep Treat if-statements like paragraphs, where each if-elsif-else grouping is like a set of sentences. Put blank lines before and … Continue reading Ruby the Hard Way: Designing and Debugging