English 中文(简体)
Spaghetti Railways Routing and Invitation Coding Bolognese
原标题:Spaghetti Rails Routing and Invitation Coding Bolognese

www.un.org/Depts/DGACM/index_spanish.htm 我并不真心实意地确定,如果存在一个单一问题,或者我以错误的方式对待这个问题,但任何建议都将受到高度赞赏。

用户在申请时表示他们获得了特权,并建立了自己的网页,然后可以通过电子邮件邀请同事。

电子邮件的启动代码在结尾。 缩略语为“/user/new/xxxxxxx

www.un.org/Depts/DGACM/index_spanish.htm 问题: 我需要同事也能够建立一个用户账户,其基本信息是正确的,这样他们就能够进入账户,并打上其角。

When the colleague makes a mistake on the user sign up form, the url forgets there is an activation code, and jumps back with validation messages and a pretty bare url of /users . When the colleague amends their mistakes and clicks sign up, they are submitted as a fully fledged user, not an invited colleague.

之所以出现这种情况,是因为在用户/新网页上有一个条款。

<% if @activation_code %>
  Show colleague messages of invitation and happiness
<% else %>
  Show fully fledged user ego stroking messages
<% end %>

我在寻找卢尔的密码参数时,是:

map.signup  /users/new/:code , :controller =>  users , :action =>  new , :code => nil

同我前面说过一样,我是否对待这一完全错误? 这里有一个问题?

UPDATE This Rails Cast Episode Solved nearly all of the problems I was having: Beta Invitations

虽然要区分当事人是否来自邀请,还是我只是利用这一条件:

if !@user.invitation_id.blank?

并且发挥了巨大作用。

最佳回答

猜测你的控制者会这样做:

def create
  if @user = User.create(params[:user]) && @user.new_record?
    #take the user to where you want them to go
  else
    #there was an error
    flash[:error] = "Oops, blah blah blah"
    render :action => "new"
  end
end

问题在于,你有“@activation_code in the view nomore。 因此,我建议你通过启动——以隐蔽的形式重新编码。

def create
  @activation_code = params[:activation_code]
  if @user = User.create(params[:user]) && @user.new_record?
    #take the user to where you want them to go
  else
    #there was an error
    flash[:error] = "Oops, blah blah blah"
    render :action => "new"
  end
end

因此,如果你从行动中提出“新”观点,你的意见仍将有必要的“@activation_code,以帮助它提出适当的条件要素。

问题回答

一旦他们使用确认代码访问该网页,你可以考虑将确认代码列入<编码><input category=“hidden”/> tag to insure that it s Save between postbacks.

否则,你需要修改你签字表格的行动,以包括启动守则;例如:

form_for @user, :url => "/users/new/#{@activation_code}" do |f|
# ...
end




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签