Today I Learned

5 posts by szymonlach

Form with multiple submit buttons

When you need to use the form in rails with submitting to different URL, you probably will try to handle it with js. Now you don’t need to, just use formaction on submit button. The formaction override the URL in form action and used its own.

<%= form_for @article, url: {action: "create"} do |f| %>
  <%= f.text_field :title %>
  <%= f.text_area :body, size: "60x12" %>
  <%= f.submit "Create" %> #this will use URL from form
  <%= f.submit "Create Draft Article",  formaction: '/draft_articles' %> #this will use URL from formaction
<% end %>

Two ways of initiating team building during a meetup

The first way of encouraging people to get to know each other during a meetup is to begin the event with the networking part. You can start a discussion about the topics of the presentations from the agenda. By asking the crowd about their suggestions about the aforementioned matter you give people some space to articulate their thoughts and share opinions with one another.

In my opinion, this approach may not always work so well. Why? Because a lot of people will not engage in a conversation as for some of them expressing their thoughts in front of people they do not know so well could be stressful. They might also feel like they do not know the topic well enough to give any constructive comments or they are simply not interested in a given subject. We also should take into consideration that some people are simply shy and do not like to be the center of attention. In the end, people form groups by themselves, always made up of those who are more or less acquainted with, that is why the problem of pushing people out of their comfort zones to mingle appears.

So how to help them in talking to one another and connect more people during the meetup? Let’s take a closer look at the second way of initiating team building during an event like this.

You can create groups at random, which gives you a higher chance of having small groups of people who have never met before. The participants will find interesting topics to discuss by themselves, especially if you help them a bit by printing out and distributing some typical IT topic ideas. Never strictly dictate the topic, though. They should feel like in a normal, friendly meeting. From my experience, this is a much better solution. This way of organizing meetups gives people more opportunities to talk. We can find a subject which we are interested in. So for shy, not confident people, we are lowering the bar for joining the conversation, speaking up and sharing their opinions.

Summary/comment: To sum everything up, I had the opportunity to participate in both of the above-mentioned types of meetings (these were meetings of the Ruby Users Group) and in my humble opinion, the latter was in many ways superior when it came to making people talk to each other and enabling them to get to know each other better.

Difference between <<~ and <<-

If you use heredoc in ruby you can choose one of two syntaxes the first <<- it takes all whitespace before stared of text so

def custom_html  
  <<-HTML
    <html>
      <body>
      </body>
    </html>
  HTML
end    

so if you will get string with all withspaces " <html>\n <body>\n </body>\n </html>\n" second <<~ will strip it so

def custom_html  
  <<~HTML
    <html>
      <body>
      </body>
    </html>
  HTML
end

will give you will get text "<html>\n <body>\n </body>\n</html>\n"

Capybara::Selenium

When you not only use Capybara for rspec, you would like to change the wait time to visit the page, so I think it can be useful.

   Capybara.register_driver :selenium do |app|
      client = Selenium::WebDriver::Remote::Http::Default.new
      client.read_timeout = 20
      Capybara::Selenium::Driver.new(app, browser: :chrome,  http_client: client)
    end