Dmitrii Amelchenko


10,430 Experience
94 Lessons Completed
1 Question Solved


Posted in How to install TailwindCSS 1.0 with Rails 6 Discussion

require('postcss-import') should be at the top of postcss.config.js, it won't break @import 'file.css'; if using CSS instead of SCSS.

The next major version of Bootstrap will be without jQuery

Posted in Tracking Metrics with Ahoy and Blazer Discussion

If using the webpacker and the latest ahoy 2.0, my browser's console returns: "ahoy is not defined", but a ruby side are working good! Can I fix that?
import ahoy from "ahoy.js";

Posted in Undo Sending Button like GMail Discussion

awesome 🔥

Posted in How to build options on select tag with VueJS?

For example, let's move to episode "using VueJS for Nested Forms in Rails" and adding model called Position, which association with a Player (belongs_to). And how to implement select tag for choosing Player's position on the nested forms?

Posted in Code Review: Run Number Refactoring Discussion

Very useful, code review series is awesome

Posted in Is possible to check boolean value by JS?

In Rails 4 app i need to implement bootstrap modal when user comes for first time and accept the terms.
I'm trying to do something like this:

= content_tag :body, data: { accept_terms: current_user.accept_terms? } do

current_user.accept_terms? - just instance method returns true or false

$(document).on 'page:change', ->
return unless $('body').data('accept-terms')
$('.terms-modal').modal 'show'

Posted in I want to understand how basecamp separates account?

Is part 3319000 of url just a show action in the controller or is there implemented by gems? Will be great to see some examples. Sorry for my english.

You can do something like <%= render 'favorites/favorites', favorites: @user.favorites %> to render partial favorites/_favorites.html.erb

Posted in Cloning nested fields by JS/coffeescript

SImple app has a two models and does the function to add nested model fields dynamically through JavaScript. But this stuff does not working with the Turbolinks 5. How to refactoring this code by JS/coffeescript, classes and data-behavior?


Ticket has_many :items, dependent: :destroy


module ApplicationHelper
    def link_to_add_fields(name, f, association)  
        new_object = f.object.class.reflect_on_association(association)  
        fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |i|  
            render(association.to_s.singularize + "_fields", :f => i)  
        link_to name, "#", :onclick => h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")")


function add_fields(link, association, content) {
    var new_id = new Date().getTime();
        var regexp = new RegExp("new_" + association, "g");
    $(link).parent().before(content.replace(regexp, new_id));


<h4 class="page-header">Items</h4>
<%= f.fields_for :items do |i| %>
    <%= render 'item_fields', f: i %>
<% end %>
<div class="form-group">
    <%= link_to_add_fields 'Add Item', f, :items %>  

Posted in How to build REST APIs?

Posted in Pundit scopes

Chris thanks!

Posted in Pundit scopes

Hi, i have no idea how to choose best way. There are three models User, Department and Task. Each user assigned to one department (belongs to). Department has many tasks. How to write a policy or something to do without using Pundit, when user can see only tasks from assigned department?