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
@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 / 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
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")
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'
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])