Complex views
We are going to make use of another open source library that has been developed to add some functionality to the Sinatra framework and make programming easier. It is called Padrino
and you can find more information about it on http://www.padrinorb.com/. Together with Padrino
, we need to install a gem called Tilt
. We point to specific gem versions in order to avoid conflicts.
Add Padrino
and tilt
to your Gemfile:
And don't forget to bundle
.
Next step, as usually when we add a library, is to both require and register the modules we want to use. Padrino
comes bundled with a lot of modules but for now, we only want to make use of so called Helper methods.
Add padrino/helpers
to your application.rb
(The :protect_from_csrf
method is a security measure to avoid hacking attacks, more on that later. For now, let's just enable that.)
You also need to create additional routes in your application.rb
in order to show the index and create interface and also to actually create a course. That will be a post
route.
Modify your views/index.erb
to look like this:
Create a new folder in views
named courses
and add two files in that folder: index.erb
and create.erb
In the index.erb
let's add a link to create a new course:
And in the create.erb
let's add a form to create a course:
Now when we run cucumber again we will get a new error:
That is a kind of a blocker for us. We need to create a Course
class. So lets do that really quick - we will add more functionality to that class later. In the lib
folder, create a course.rb
file and add the following code:
And require that class in your application.rb
:
Now, try to run your tests again. What does it looks like?
As a last step this part I would like you to add two step definitions {really??? what defs is that???}
Last updated