- 浏览: 94260 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
xylffxyfpp:
应该改成慎用each
万恶的"delete",慎用数组的delete -
xylffxyfpp:
a = [1,2,3,4,5,6]
a.each do ...
万恶的"delete",慎用数组的delete -
CaiDeHen:
受教了,我也不知道当时为什么会在这个地方这样子用。其他地方也是 ...
万恶的"delete",慎用数组的delete -
wosmvp:
感觉太乱了为什么不在User模型中来个 named_scope ...
万恶的"delete",慎用数组的delete -
jiachengxi38:
不知道楼主这样的逻辑想法从何而来,权限访问的思想好像在lZ这里 ...
万恶的"delete",慎用数组的delete
You know those invitation systems where a given user can invite a number of other people to join? That's what I show you how to make in this episode.
script/generate nifty_scaffold invitation sender_id:integer recipient_email:string token:string sent_at:datetime new script/generate migration add_invitation_to_users invitation_id:integer invitation_limit:integer script/generate mailer Mailer invitation # models/invitation.rb belongs_to :sender, :class_name => 'User' has_one :recipient, :class_name => 'User' validates_presence_of :recipient_email validate :recipient_is_not_registered validate :sender_has_invitations, :if => :sender before_create :generate_token before_create :decrement_sender_count, :if => :sender private def recipient_is_not_registered errors.add :recipient_email, 'is already registered' if User.find_by_email(recipient_email) end def sender_has_invitations unless sender.invitation_limit > 0 errors.add_to_base 'You have reached your limit of invitations to send.' end end def generate_token self.token = Digest::SHA1.hexdigest([Time.now, rand].join) end def decrement_sender_count sender.decrement! :invitation_limit end # models/user.rb validates_presence_of :invitation_id, :message => 'is required' validates_uniqueness_of :invitation_id has_many :sent_invitations, :class_name => 'Invitation', :foreign_key => 'sender_id' belongs_to :invitation before_create :set_invitation_limit attr_accessible :login, :email, :name, :password, :password_confirmation, :invitation_token def invitation_token invitation.token if invitation end def invitation_token=(token) self.invitation = Invitation.find_by_token(token) end private def set_invitation_limit self.invitation_limit = 5 end # invitation_controller.rb def new @invitation = Invitation.new end def create @invitation = Invitation.new(params[:invitation]) @invitation.sender = current_user if @invitation.save if logged_in? Mailer.deliver_invitation(@invitation, signup_url(@invitation.token)) flash[:notice] = "Thank you, invitation sent." redirect_to projects_url else flash[:notice] = "Thank you, we will notify when we are ready." redirect_to root_url end else render :action => 'new' end end # users_controller.b def new @user = User.new(:invitation_token => params[:invitation_token]) @user.email = @user.invitation.recipient_email if @user.invitation end # routes.rb map.signup '/signup/:invitation_token', :controller => 'users', :action => 'new' # models/mailer.rb def invitation(invitation, signup_url) subject 'Invitation' recipients invitation.recipient_email from 'foo@example.com' body :invitation => invitation, :signup_url => signup_url invitation.update_attribute(:sent_at, Time.now) end <!-- mailer/invitation.erb --> You are invited to join our beta! <%= @signup_url %> <!-- invitations/new.html.erb --> <% form_for @invitation do |f| %> <p> <%= f.label :recipient_email, "Friend's email address" %><br /> <%= f.text_field :recipient_email %> </p> <p><%= f.submit "Invite!" %></p> <% end %> <!-- home/index.html.erb --> <p>We are currently in private beta. Please submit your email address below, and we will notify you when we are ready to accept more users.</p> <% form_for Invitation.new do |f| %> <p> <%= f.label :recipient_email, "Your Email:" %> <%= f.text_field :recipient_email %> <%= f.submit 'Submit' %> </p> <% end %> <!-- users/new.html.erb --> <%= f.hidden_field :invitation_token %>
发表评论
-
#125 Dynamic Layouts
2008-12-13 21:41 887Discover how to dynamically cha ... -
#123 Subdomains
2008-12-13 15:56 1068Learn how to unleash the full p ... -
#122 Passenger in Development
2008-12-13 15:51 832Tired of juggling multiple Rail ... -
#121 Non Active Record Model
2008-12-13 15:47 890This episode will show you how ... -
#120 Thinking Sphinx
2008-12-12 16:59 859If you need a full text search ... -
#119 Session Based Model
2008-12-12 16:41 1015If you have a lot of logic asso ... -
#118 Liquid
2008-12-12 16:18 874Liquid is a safe way to provide ... -
#117 Semi-Static Pages
2008-12-12 14:20 829Static pages can sometimes be a ... -
#116 Selenium
2008-12-12 14:11 809Selenium is a great way to test ... -
#115 Caching in Rails 2.1
2008-12-12 14:07 862Rails 2.1 brings some new cachi ... -
#114 Endless Page
2008-12-12 13:50 1005Ever wondered how some sites se ... -
#112 Anonymous Scopes
2008-12-12 13:32 835The scoped method allows you to ... -
#111 Advanced Search Form
2008-12-12 13:27 742If you need to create an advanc ... -
#110 Gem Dependencies
2008-12-12 12:57 760In Rails 2.1 we now have the ab ... -
#109 Tracking Attribute Changes
2008-12-12 12:54 798Rails 2.1 keeps track of the ch ... -
#108 named_scope
2008-12-12 12:52 748The named_scope method in Rails ... -
#107 Migrations in Rails 2.1
2008-12-12 12:49 690Migrations now have a timestamp ... -
#106 Time Zones in Rails 2.1
2008-12-12 12:48 718In the past, time zones have be ... -
#104 Exception Notifications
2008-12-12 11:48 712If you're running a production ... -
#103 Site Wide Announcements
2008-12-12 11:42 833Sometimes you need to display a ...
相关推荐
git clone https://github.com/hi-ashleyj/accept-github-invitations.git 在根目录中创建config.json文件,并使用repo:invite范围添加个人访问令牌 { " access_token " : " <YOUR> " } 与运行 node app.js # or...
**Python-django-invitations:为django-allauth集成的邀请模块** `django-invitations` 是一个专为 Django Web 开发框架设计的扩展库,它为基于 `django-allauth` 的应用程序提供了一个用户邀请系统。`django-...
【标题】"invitations:邀请函"所指的是一款与活动邀请相关的应用程序,可能是用于创建、管理和发送电子邀请函的工具。在这个项目中,开发者可能提供了用户友好的界面和定制功能,使得用户能够轻松地为各种活动(如...
用户单击链接,确认其电子邮件并将其重定向到注册注册网址中已预填了电子邮件,注册后,用户将登录到该网站通用安装pip install django-invitations# Add to settings.py, INSTALLED_APPS'invit
"ploneintranet.invitations" 模块显然是 Ploneintranet 中的一个组成部分,专注于邀请功能,可能涉及到用户注册、团队协作和事件管理等场景。 描述中提到这个包已经被合并到主存储库 "ploneintranetploneintranet...
邀请函查看项目设置npm install编译和热重装以进行开发npm run serve编译并最小化生产npm run build整理和修复文件npm run lint自定义配置请参阅。
本文档详细介绍了人人网 API 接口的使用说明,包括 admin、Connect、Friends、Invitations、Notifications 等多个模块的接口详细说明。 admin 模块 admin.getAllocation 接口用于获取一个应用当天可以发送的通知的...
并邀请他们参加业务需求研讨会(Identify Key Stakeholders/Business Owners for the Business Requirements Workshop and Send Invitations),以及记录部门级业务计划的需求(Document Departmental Business ...
标题《2020YCBCTF羊城杯官方Writeup.pdf》中的“YCBCTF”指的是一种名为“羊城杯”的网络安全竞赛(CTF),这是一个以网络安全为主题的竞赛,CTF全称Capture The Flag,即“夺旗赛”,是一种信息安全竞赛活动。...
Invitations.getInfo 接口用于根据应用新用户的 id 获取用户的是否通过邀请安装,同时得到此次邀请的详细信息。这个接口可以帮助开发者获取用户的邀请信息。 Notifications.send 接口 Notifications.send 接口用于...
# The Party Program -- Invitations to friends from the # "guest" file guestfile=./guests if [[ ! -e "$guestfile" ]] then printf "${guestfile##*/} non-existent" exit 1 fi export PLACE="Sarotini's" (...
时光云端·云端新时代.apk.1
自动选择所有Facebook好友的活动邀请。 *状态:*废弃版本3.0.0是此扩展程序的最终版本。 自2014年11月起,此扩展程序不适用于Facebook。 我已决定停止维护此扩展。 Facebook的新更新具有内置的“全选”功能,从而使...
NodeBB用户邀请该NodeBB插件允许当前用户向潜在的新用户发送电子邮件邀请。发送邀请用户可以从个人资料链接菜单上列出的“邀请”页面发送邀请。 管理员还可以从ACP中的“用户邀请”页面发送邀请。...
4. **提供邀请**(Offer Invitations):鼓励用户与界面互动,提供清晰的操作指引。 - 示例:通过视觉提示(如按钮高亮)引导用户采取行动。 5. **使用变换**(Use Transformations):通过动画等视觉效果增强用户...
Google Music Player 谷歌音乐播放器 ...这个APK本来Google只是开放给米国for download only, 而且需要apply a google music account,并自己上传到Google的music中心。...7 invitations remaining only,先到先得。
这个扩展插入js ... 脚步: 1-登录到linkedIn 2-访问http://www.linkedin.com/inbox/invitations/sent 3-看魔术发生:) fyi:如果速度缓慢或出现任何意外的行为>>>重新启动Chrome <<<。 十分感谢: ...
此外, src/ruby/invitations.template.txt必须另存为src/ruby/invitations.txt并且还应该有一个电子邮件地址。 从...开始: ./config.rb build ./config.rb up config.rb写入docker-compose.yaml ,然后使用传递...
Invitations and characteristic numbers. Topology, 1998, 17: 309-330 - [2] CONNER P E, FLOYD E E. Differentiable Periodic Maps. Berlin: Springer Verlag, 1964. - [3] CAPOBIANCO F L. Stationary points ...
波兰人ESS网站 资讯 配置初始设置: ...n 100000> logs.txtscalego运行rake salesforce:send_all_automatic_invitations --app pole-ess-staging标度-a pole-ess-staging运行- -env RAILS_MASTER_KEY =值 EDI