patrikbona.com
JavaScript localization in Ruby on Rails
http://patrikbona.com/blog/javascript-localization-in-ruby-on-rails
September 25, 2015. JavaScript localization in Ruby on Rails. Localization (or internationalization) in Rails is easy. But there is no built in support for JavaScript localization. Luckily it is very easy to implement it. 1) Add your translations to the locale file under the. 2) Include it into the head section of your layout. App/views/layouts/application.html.erb . %=. Window.I18n = %=. 3) Use it in your JavaScript files. My name is Patrik Bóna and I am the only programmer at Memberful.
patrikbona.com
Think twice, name it once
http://patrikbona.com/blog/think-twice-name-it-once
January 29, 2014. Think twice, name it once. There are many best practices for improving your code readability. One of them is to use proper names for classes, methods, objects,. For everything. Lets check the code below. Can you quickly guess what it does? According to methods name it fixes some position. But lets check the same code again, just with the better method name. Keep robot in arena. Keep robot in the arena. My name is Patrik Bóna and I am the only programmer at Memberful. Follow me on Twitter.
patrikbona.com
Sending POST data with links (AJAX)
http://patrikbona.com/blog/sending-post-data-with-links
January 23, 2014. Sending POST data with links (AJAX). Handling AJAX requests in Rails. Is pretty easy thanks to the jquery-ujs. Library. This library is enabled by default in every new Rails application. You can do standard, but also some pretty crazy things with it with ease. For example you can send POST data with AJAX after click on the HTML link element generated with. AJAX action with POST request'. Above code will generate following HTML (but with escaped quotes in data-params).
patrikbona.com
Better content assertion for MiniTest and Capybara
http://patrikbona.com/blog/better-content-assertion-for-minitest-and-capybara
June 23, 2015. Better content assertion for MiniTest and Capybara. I like to play with. It is the opposite of. Almost no DSL and a lot of pure Ruby code. You can use. Syntax, but I dont like it. But there is one drawback. If I want to make a content assertion with. Then I have to do something like this:. The issue is that this assertion is reticent:. 1) Failure: EventsTest#test event search [integration test.rb:17]: Failed assertion, no message given. Please note this part:. Q{Expected to found ".
patrikbona.com
Creating a Ruby gem
http://patrikbona.com/blog/creating-a-ruby-gem
February 5, 2014. Creating a Ruby gem. There are different ways to create a new Ruby gem. I will show you how to do it with ease using bundler. 1) Generate all needed files. This will create all needed files and prepare new rake tasks for you. 2) Edit gem specification in. 3) Add your Ruby files to. And make sure that they are required from. Also do not forget to create own namespace (module) for your code. Your code goes here. Lib/awesome gem/awesome class.rb. 4) Add your tests to. Then add this to your.
patrikbona.com
Removing complexity
http://patrikbona.com/blog/removing-complexity
May 17, 2016. Ive started at a new job last year. It was a pretty quick change. Ive quit my old job. One week and started in the new one next week. It is awesome, because I am the only programmer. I work at Memberful. For example, today I got rid of last pieces of pjax. Ive replaced it with Turbolinks. It was a simple change, but for me it was important. Because now there is 103 less lines of code which I need to maintain. My name is Patrik Bóna and I am the only programmer at Memberful.
patrikbona.com
Show form errors next to the form fields
http://patrikbona.com/blog/show-errors-next-to-the-form-fields
January 16, 2014. Show form errors next to the form fields. Ruby on Rails doesnt show form errors next to the form fields out of the box. But this behaviour can be implemented with few lines of code. As fisrt create new form helper. Span br / ". And the use it in your form viewes. Above code will show all related erros for. I believe that this behaviour is provided by some gems, for example simple for. But you can use my solution if you do not want to have additional functionality. Follow me on Twitter.
patrikbona.com
Authenticating with HTTP basic authentication from request specs
http://patrikbona.com/blog/http-basic-auth-in-specs
July 14, 2014. Authenticating with HTTP basic authentication from request specs. In one of my previous posts. I mentioned that I used HTTP basic authentication for REST API. In this post I will show you how to authenticate with HTTP simple authentication from RSpec request specs. In the example below you can see one API spec and then different private methods for HTTP. Retrieves all runs for user'. As you can see, basic RSpec methods are used with some additional parameters. The most important is.
patrikbona.com
Multiple authentication ways in one application
http://patrikbona.com/blog/multiple-authentication-ways-in-one-application
July 10, 2014. Multiple authentication ways in one application. I was recently working on one simple application and I needed to create REST API for all user actions. Users were authenticated with standard HTML signin forms, but this was not possible for API. So I decided to add HTTP basic authentication to my application, but just for API calls. Implementation was pretty simple. Method checks request type and then decide which type of authentication will be used. Authenticate user with http basic.
patrikbona.com
Selenium vs. Poltergeist vs. Capybara-webkit. Which one is the fastest?
http://patrikbona.com/blog/selenium-vs-poltergeist-vs-cabybara-webkit
July 11, 2014. Selenium vs. Poltergeist vs. Capybara-webkit. Which one is the fastest? I know three web drivers for running JavaScript tests with capybara. Selenium. Which is the default), poltergeist. Webdriver starts firefox and perform all tests in it. On the other hand. Are headless wekbit browsers, so there are no windows popping up. There are of course also other differences between these web drivers, but I was mainly curious in the speed. But there is a huge gap between. Follow me on Twitter.