This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| match '/:id', to: 'refinery/blog/categories#show', constraints: { id: /(?!.*?refinery).*/ } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def self.dedupe | |
| # find all models and group them on keys which should be common | |
| grouped = all.group_by{|model| [model.title,model.info,model.address,model.phone] } | |
| grouped.values.each do |duplicates| | |
| # the first one we want to keep right? | |
| first_one = duplicates.shift # or pop for last one | |
| # if there are any more left, they are duplicates | |
| # so delete all of them | |
| duplicates.each{|double| double.destroy} # duplicates can now be destroyed | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $('[data-modal]').click(function(e){ | |
| e.preventDefault(); | |
| $($(this).data('modal')).modal().open({ | |
| onOpen: function(el){ | |
| $('.like').click(function(e){ | |
| e.preventDefault(); | |
| if ($(this).hasClass('u_like')) { | |
| $.ajax({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| = link_to dialog_path dialog.participant.id, class: 'person' | |
| img.person src="http://lorempixel.com/80/80/" | |
| p | |
| = "#{dialog.participant.name} #{dialog.participant.last_name}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| })(jQuery); | |
| (function($) { | |
| $.noty.themes.defaultTheme = { | |
| name: 'defaultTheme', | |
| helpers: { | |
| borderFix: function() { | |
| if (this.options.dismissQueue) { | |
| var selector = this.options.layout.container.selector + ' ' + this.options.layout.parent.selector; | |
| switch (this.options.layout.name) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ApplicationController < ActionController::Base | |
| check_authorization unless: :devise_controller? | |
| protect_from_forgery | |
| before_action :cancan_patch, :create_user | |
| protected | |
| def cancan_patch | |
| patched_controllers = %w(orders invoices) | |
| if request.post? && action_name == 'create' && patched_controllers.include?(controller_name) | |
| resource = controller_name.singularize.to_sym |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def market | |
| if params[:order_id] && params[:order_status] | |
| order = Order.find(params[:order_id]) | |
| if params[:order_status] == :declined | |
| current_user.decline_order order # исключает заказ из списка доступных | |
| else | |
| current_user.accept_like order # записывает исполнение заказа, исключает его из доступных заказов | |
| end | |
| end | |
| @order == current_user.get_avaliable_order # возвращает доступный для этого пользователя заказ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create_documents | |
| order = self.order | |
| customer_doc = order.documents.create! | |
| contractor_doc = self.documents.create! | |
| customer_doc.tranzactions.create! account_id: order.user.accounts.transit.id, amount: (order.price * -1) | |
| contractor_doc.tranzactions.create! account_id: self.user.accounts.transit.id, amount: (order.price * +1) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| h1 Маркет | |
| br | |
| - if @order.nil? | |
| h2 Заказы отсутствуют | |
| - else | |
| h2 =' @order.price | |
| =' link_to 'Лайк', process_operation_order_path(id: @order.id, order_status: :accepted), method: :post | |
| = link_to 'Отклонить', process_operation_order_path(id: @order.id, order_status: :declined), method: :post | |
| - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Setting < ActiveRecord::Base | |
| enum type: {integer: 0, string: 1, storage: 2} | |
| enum_features :type | |
| store :value, coder: JSON | |
| after_find :match_types | |
| before_save :save_types | |
| validates :value, numericality: { only_integer: true }, if: 'integer?' | |
| validates :title, uniqueness: true |
OlderNewer