English 中文(简体)
• 如何改用海关档案
原标题:how to redirect_to a custom html file

我有某种联系,希望用户报到,在缺席的情况下,我会接触到一种习惯观点(新工人.html)。

目前,我有一个链接,即我控制人员内部的一种方法,即把谁来检查工作人员用户会议类型,以决定用户应转向哪里。

edit: as pointed out by the commenters the answer is to call the relevant controller to your view in your link_to, then perform the check for the right render inside the controller like so:

   if session[:user].staff_type == 3
        render "new_worker"

指出相关观点中新的“工人”观点

最佳回答

因此,不同的工作人员类型不同? 工人是其中之一。

如上所示,在你的工作人员控制人员中,我或许会做些什么,这就是,我认为你想要提出一个不同的模板,而当你重新审视某个有特定工作人员的人时——就是找到工作人员,然后看他们:工作人员——类型,如果或某个案件能够提供相应的部分。

def show
  @staff = Staff.find(params[:id])

  case @staff.staff_type
  when "worker"
    render :action => "show", :layout => "worker" 
  else
     #other options
  end
end

以上是显示行动(绕过这些变量)的结果,而是一种称为工人的习俗。

或者,我建议使用同样的kel子,然后对不同类型的工作人员作不同的部分,而不是像上一样,这样就能够:

render :partial => "worker", :object => @staff

In that case, the view would be called probably _worker.rhtml

See info here:

你们可以在任何控制者的行动中真正使用上述手段。 但是,你们需要以控制者的身份这样做,或者重新组织你们的资源。

问题回答

It is not clear at all, give us a bit more information what are absence, staff_type, worker ? do you have route, resource and controller for all these things, are they linked through relations ?

基本答案是: 有了铁路,为了提供一个模板,你需要一名控制员和一条通往控制器的通道。 然后是快速的<代码>redirect_to new_worker_path。 工作

EDIT : routes point to actions, which render views (or other http response such as redirect_to).

铁路(如果对你的猜测为2.3.11)是一个以资源为导向的铁路。 如果你想有一个不同的工作人员类型模板,那么你就应当保持这种联系,并转而采用新的“ab”模式,你可以在你的链接<条码>上添加一个论点:打字;打字;工人,并在你的控制人中利用这个论点来提供具体的模板。

the not best practice way, is to create a route and an action. for rails 2.3.11

map.resources :staff, :member => {:new_worker => :get}

then define in your staff controller :

def new_worker
  ...
  render  new.worker 
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: ...

热门标签