React and redux really make building a website easy. By being able to compartmentalize the code you can track down the errors much faster and with greater ease. Regular JavaScript function like map and filter can be thrown in any component you create. This makes it supper easy to make the website interactive. The hardest challenges I found was how it all talked to each other but after doing a full build I was able to create more stuff efficiently. Knowing what the state and props are doing and when to call them is the most important part I found in react. Using Middleware, Connect and Thunk made this much easier. The code to make these work is extremely straight forward.
Building a Rails API was really easy and quick by using the rails new and scaffolding commands. Creating functionality this way was made very simple and efficient. Serializers also make it really easy to add more components to the site for quick development. Even using JavaScript for the front end you can still watch the server update with sql code allowing you to know if its doing what you want it to do.
Rails has many built in methods that can assist making it much easier to get up and running. There are quite a few filters and validations that can be applied to make it dryer and not repetitive with code. You can apply filters before, around and after in controllers but one commonly used is the before_action to check if the a user is logged in etc. The before_action filter is run before any methods are run in the controller. Filters on the application controller will inherit to all controllers but if the before_action filter is used on any other controller it will only be applied to just that controller.
I found this subject to be quite hard. It’s great that you can accomplish so much with very little code but the number of things it can do is a bit overwhelming. I found it hard to know when to use certain helpers and when I needed custom methods. I found methods like the before_action to be very helpful. before_action :require_permission, only: :show
I found this project to be great fun but did run into a few hurdles. First the defaults that Cornial created caused me issues and broke pry so I was stuck using just the errors in the browser and a rake counsel. The default config.ru file also caused me issues with my edit pages giving a 500 error. After commenting this line out it all worked.
rake db:migrate
to resolve the issue.’I had struggled in the past with using gsub expressions but feel I learned a great deal writing this one. This one goes through a block of text and grabs any image URL’s and adds an image source tag on it so it will render in the browser.
regexp = /(\S+.(jpg|gif|png)(\/\S+)?(.*))/
@description = @route.description.gsub(regexp) { |url| “” }
I really learned how all the aspects of what I had been studding do and how to adapt them into a working environment. It was also really exciting to see with Sinatra and Active Record how much functionality you can get with very little code.
I decided to do something with my project that I would actually use. I will be publishing it in a live environment and using it to log stuff for myself so it feels even more satisfying to make it work well.