Skip to content

Instantly share code, notes, and snippets.

View Nursultan91's full-sized avatar
🎯
Focusing

Nursultan Kuzhagaliyev Nursultan91

🎯
Focusing
  • Almaty, Kazakhstan
View GitHub Profile
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:username, :email, :password, :password_confirmation, :remember_me])
devise_parameter_sanitizer.permit(:sign_in, keys: [:username, :email, :password, :password_confirmation, :remember_me])
Rails.application.routes.draw do
devise_for :users
get 'pages/about'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
Rails.application.routes.draw do
devise_for :users
get 'pages/about'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
ActiveAdmin.register Project do
permit_params :name, :content, :price, :image
show do |t|
attributes_table do
row :name
row :content
row :price
row :image do
project.image? ? image_tag(project.image, height: '100') : content_tag(:span, "No photo yet")
@Nursultan91
Nursultan91 / app_admin_user.rb
Created May 16, 2017 09:31
Вот что я написал в файле app/admin/user.rb
ActiveAdmin.register User do
permit_params :email, :name, :paid, :user_id
show do |t|
attributes_table do
row :email, label: "Почта"
row :name, label: "Имя"
row :paid, label: "Статус оплаты"
end
@Nursultan91
Nursultan91 / file.rb
Created May 17, 2017 16:06
То как я все сделал
#Вот модель task.rb
class Task < ActiveRecord::Base
extend FriendlyId
friendly_id :title, use: [:slugged, :finders]
has_many :taskstatus
has_many :users, through: :taskstatus
#Вот модель user.rb
class User < ActiveRecord::Base
@Nursultan91
Nursultan91 / maigraciya.rb
Created May 18, 2017 07:14
Не хочет принимать миграцию.
class CreateTaskstatuses < ActiveRecord::Migration
def change
create_table :taskstatuses do |t|
t.reference :user
t.reference :task
t.string :task_status
t.timestamps null: false
end
<div class="card-action grey-text text-darken-4">
<form action="#">
<div class="file-field input-field">
<div class="btn">
<span>Сдать отчет</span>
<input type="file" multiple>
</div>
<div class="file-path-wrapper">
<%= form_tag.file_field :reports, :class=>"file-path validate", :placeholder => "Загрузите один или более файлов", multiple: true %>
</div>
class Users::RegistrationsController < Devise::RegistrationsController
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
# GET /resource/sign_up
# def new
# super
# end
# POST /resource
@Nursultan91
Nursultan91 / index.rb
Created June 8, 2017 09:22
Страница reviews/_index.html.erb
<% if @reviews.blank? %>
<span class="center"><h4>У этого курса пока нет отзывов</h4></span>
<% end %>
<% @reviews.order("id desc").each do |r| %>
<hr>
<div class="row">
<div class="col m1">
<%= image_tag avatar_url(r.user), class: "circle responsive-img avatar-small" %>