1. Button Behavior Inside a Form

    A form is usually associated with a submit button. In Rails, you typically have a form specified as following: (if use form_for helper) <%= form_for(@meeting) do |f| %> <%= render "shared/error", :target => @meeting %> <div class="panel panel-default"> <…

  2. Set Up Cron Jobs in Rails

    Recently I came to a situation where I need to take an action based on time. For example, a web application helps organizing an event and 48 hours before its scheduled time, it'll send out a reminder email to all attendees. It's not triggered by view,…

  3. Write a Helper Extension

    In Rails development, it comes often that you want to add/remove certain function that Rails pre-defined. For example, if you use Bootstrap 3, to have a form format correctly, each text_field needs to have class form-control. The best way to achieve that is to write a helper extension…

  4. Some testing functions with MiniTest and Capybara

    I'm testing this piece of Rails HTML code and its click function: <tr> <td class="arrow-uped" id="tupa" onclick="send_vote()"> </td> <td rowspan="3" class="restname"> Chipotle </td&…

  5. Rails Pluralize Function

    Rails pluralize function comes in handy when you need to differentiate "1 person" and "2 people" based on users count. You could just simply do: pluralize(users.count, 'person') If you don't want the number shows up, you could do: 'person&…

  6. Render a Partial View with Ajax Call - Tutorial for Beginners

    Render a partial view in Rails is very straighforward. If you have a partial view file named _form.html.erb, in your view page, you could just do <%= render "form" %> . That's the most basic partial rendering. What about there are variables involved or the…