使用Bootstrap Bar来增加Onboarding Progress Bar功能。
git初始代码https://github.com/chentianwei411/at-mentions-with-action-text
首先,开分支onboardingbar.
然后,
- rails g scaffold Team user:references name
rails g migration AddTwitterToUsers twitter
rails db:migrate
在user.rb上添加
- has_many :teams
在_navbar.html.erb上添加导航链接:
- <li class="nav-item"><%= link_to "Teams", teams_path, class: "nav-link" %></li>
在用户注册app/views/devise/registrations/edit.html.erb上添加twitter field:
- <div class="form-group">
- <%= f.text_field :twitter, class: 'form-control', placeholder: 'Twitter Username' %>
- </div>
在application_controller.rb上添加参数白名单:
- protected
- def configure_permitted_parameters
- devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
- devise_parameter_sanitizer.permit(:account_update, keys: [:name, :twitter])
- end
添加OnboardingBar:
在app/views/home/index.html.erb
- <% if user_signed_in? %>
- <div class="progress">
- <div class="progress-bar" role="progressbar" style="width: 25%"></div>
- </div>
- <%= current_user.twitter? %>
- <%= current_user.teams.any? %>
- <% end %>
下一步,user.rb添加方法来判断onboardingbar的进度:
- def onboarding_percent
- steps = [:twitter?, :has_team?]
- conplete = steps.select{ |step| send(step)}
- complete.length / steps.length.to_f * 100
- end
- def has_team?
- teams.any?
- end
- # select()方法,筛选返回值为true的数组项
- # Ruby#send()方法,可以使用symbol符号方法
# 方法最后返回的值的计算必须使用浮点格式,不能是整数格式。使用to_f。
在views/home/index.html.erb,从bootstrap拷贝下来进度条代码,并修改
使用Bootstrap Bar来增加Onboarding Progress Bar功能。的更多相关文章
- WPF 4 开发Windows 7 任务栏(Overlay Icon、Thumbnail Toolbar、Progress Bar)
原文:WPF 4 开发Windows 7 任务栏(Overlay Icon.Thumbnail Toolbar.Progress Bar) 在上一篇我们介绍了如何在WPF 4 中开发Wind ...
- unity3d插件Daikon Forge GUI 中文教程5-高级控件listbox和progress bar的使用
3.3.listbox列表框 Atlas 图集: 下面应用到的精灵都是在这里的. ListBox中的内容: 背景精灵 图片的主颜色 Padding边距 Scrollbar 滚动条对象的预制体或者对象, ...
- Circular progress bar in Unity 3D
Circular progress bar in Unity 3D - UnityScripthttp://stackoverflow.com/questions/22662706/circular- ...
- Create a “% Complete” Progress Bar with JS Link in SharePoint 2013
Create a “% Complete” Progress Bar with JS Link in SharePoint 2013 SharePoint 2013 has a lot new fea ...
- unity3d插件Daikon Forge GUI 中文教程-5-高级控件listbox和progress bar的使用
(游戏蛮牛首发)大家好我是孙广东.官网提供了专业的视频教程http://www.daikonforge.com/dfgui/tutorials/,只是是在youtube上,要观看是须要FQ的. 只是教 ...
- C#控制台进度条(Programming Progress bar in C# Consle application)
以下代码从Stack Overflow,觉得以后会用到就收藏一下,我是辛勤的搬运工,咿呀咿呀哟- 1.showing percentage in .net console application(在. ...
- 打印进度条——(progress bar才是专业的)
# 打印进度条——(progress bar是专业的) import time for i in range(0,101,2): time.sleep(0.1) char_num = i//2 #打印 ...
- Python tqdm show progress bar
tqdm can help to show a smart progress bar, and it is very easy to use, just wrap any iterable with ...
- how to create a ring progress bar in web skills
how to create a ring progress bar in web skills ring progress bar & circle progress bar canvas j ...
随机推荐
- C/C++ 获取系统时间 到秒 || 到毫秒
string getNowSysTime(string &outPut) { ] = {}; struct timeval tv; struct timezone tz; struct tm ...
- jquery判断字符长度 数字英文算1字符 汉字算2字符
<input type="text" maxlength="25" oninput="textlength(this)"> &l ...
- PHP 获取一篇文章内容中的全部图片,并下载
做个记录,在工作or面试中有可能会遇到function downImagesFromTargetUrl($url, $target_dir = null) { if(!filter_var($url, ...
- NetBeans远程调试Linux c++ 11项目
NetBeans远程调试Linux c++ 11项目 由于好多原因,好久没有写博客了,随着c++ 11的普及率越来越高,开发c++ 项目的人也越来越多,可以说c++ 11 给了c++ 这门语言第二次生 ...
- 【转】Install Win32 OpenSSH (test release)
Openssh download url:https://github.com/PowerShell/Win32-OpenSSH/releases Install instruction: Insta ...
- Log4j2 HelloWorld
Log4j2 使用教程 Log4j2 的好处就不在这里一一列举了,如果你搜了2,说明你对它一定有兴趣,并且想了解它,使用它. 一.下载log4j2 ,基本上你只需要导入下面两个jar包即可: log4 ...
- 【转】Anaconda下安装pyecharts步骤及常见错误
本文转载自:https://blog.csdn.net/skj1995/article/details/81187954 (1)之前看了几篇博客,有人说用cmd命令在目录C:\Users\Admini ...
- 在sql中select的执行顺序
<select{[distinct |all] columns |*}> [into table_name] <from {tables |views | other select} ...
- windows下手动安装composer并配置环境变量
windows下手动安装composer并配置环境变量 转载地址: https://my.oschina.net/7sites/blog/209997 之前发表过一篇如何为composer设置代理 ...
- ECS上nginx搭建反向代理通过内网访问阿里云OSS服务
对于付不起钱的小伙计,为了给公司省钱,想尽一切招数.今天就来分享一个使用阿里云OSS存储搭配CDN使用的网站服务器部署方法. 简介 阿里云OSS 阿里云提供的一种文件存储方案,和我们以前接触的百度云B ...