简体   繁体   English

Rails传递多个参数

[英]Rails passing more than one parameters

Respected ppl ... 尊敬的人...

I have a grave design issue since many days ...kindly help out ... 自从很多天以来,我遇到了一个严重的设计问题……请帮忙……

在此处输入图片说明

Im coming to this stage from the previous screen after entering the hospital_id which u can c from the URL is 10 (using ransack) ... at this stage when i click "Add performance detail for employee" im passing only the employee_id to the performance creation screen ... 我从输入URL可以输入URL的hospital_id后进入上一屏幕,我可以从URL进入10(使用ransack)...在此阶段,当我单击“为员工添加绩效详细信息”时,im仅将employee_id传递给绩效创建屏幕...

在此处输入图片说明

How do i capture the hospital_id from the previous screen and store in my performance creation screen ? 如何从上一个屏幕中捕获hospital_id并将其存储在性能创建屏幕中? ... (it has field hospital_id) .... ...(具有field hospital_id)...。

can i somehow use this raw sql query to store hospital_id directly ? 我可以以某种方式使用此原始sql查询直接存储hospital_id吗? ... ...

SELECT hospital_id FROM employee_sanction_working WHERE employee_id employee_sanction_working选择WHERE employee_id ID的hospital_id

Pls do help ... 请帮忙...

Thnx n

There are few ways you can resolve your problem: 有几种方法可以解决您的问题:

1) you can pass hospital_id in parameter as Rubyman and Santhosh K have suggested Or 1)您可以按照Rubyman和Santhosh K的建议在参数中传递hospital_id

2) you can create a class variable in controller which you can use in your erb or haml view. 2)您可以在控制器中创建一个类变量,该变量可以在erb或haml视图中使用。

for example: 例如:

in controller:

def new 
    @hospital_id = params[:hospital_id] #this you can use in your view
end
in view
Hospital ID is <%= @hospital_id %>

Please refer this for more information 请参考以获取更多信息

您可以将hospital_id作为参数传递给“为员工添加绩效详细信息”链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM