Skip to content

Instantly share code, notes, and snippets.

View yamaaki's full-sized avatar

Yamaya Akihiro yamaaki

  • Tokyo, Japan
View GitHub Profile
module DeviseHelper
def devise_error_messages!
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg, class: 'p-toast') }.join
html = <<-HTML
<ul class="hide">#{messages}</ul>
HTML
html.html_safe
end
- unless resource.errors.empty?
= devise_error_messages!
#member-members-registrations-edit
.row
.col.s12.m9
.section
#p-title.col.s12.scrollspy
h2.u-title Edit Profile
#member-members-sessions-new
.row
.col.s12.m9
.section
#p-title.col.s12.scrollspy
h2.u-title Sign in
= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
.input-field.col.s12.l9
ul.right.hide-on-med-and-down
- if member_signed_in?
li = link_to edit_member_registration_path, class: 'tooltipped', data: { position: 'left', tooltip: 'Edit Profile' } do
i.material-icons account_box
li = link_to destroy_member_session_path, method: :delete, class: 'tooltipped', data: { position: 'left', tooltip: 'Sign out' } do
i.material-icons exit_to_app
ul#mobile-menu.side-nav.fixed.collapsible data-collapsible="accordion"
li.hide-on-med-and-down.p-logo
= link_to root_path do
img.responsive-img src="http://dummyimage.com/400x300/eee/fff.png&text=Logo"
- if member_signed_in?
li
= nav_header :profile
.collapsible-body
ul
module ApplicationHelper
def nav_header(key)
active = false
if key == :profile
active = true if is_nav_active?(:edit_profile)
active = true if is_nav_active?(:sign_out)
text = 'Profile'
end
Member.create! email: '[email protected]', password: 'hogehoge'
class Admin < ActiveRecord::Base
devise :database_authenticatable, :trackable, :timeoutable
end
class DeviseCreateAdmins < ActiveRecord::Migration
def change
create_table(:admins) do |t|
# Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
# Trackable
t.integer :sign_in_count, default: 0, null: false
Rails.application.routes.draw do
devise_for :members, path: 'member/members'
devise_for :admins, path: 'admin/admins'
resources :members, path: 'admin/members'
mount API => '/api/'
get 'welcome/index'
root to: 'welcome#index'
match '*path' => 'application#error404', via: :all
end