【发布时间】:2013-12-01 01:38:33
【问题描述】:
我这样扩展我的路线:
photos_patient_path(@patient, {:photoid => f.id })
创建:
http://localhost:3000/patients/79799/photos?photoid=6
在我的 Rails 控制器中,我有:
def photos
@photos = @patient.photos.paginate(:page => params[:page], :per_page => 8)
@photo = @photos.find(params[:photoid]) rescue nil
@termins = @patient.termins.where("date >= ?", Date.today)
render :show
end
在视图中:
<% if @photo == nil %>
<%= render 'patient_photos' %>
<% else %>
<%= render 'patient_photo' %>
<% end %>
上面的代码有效,现在我尝试添加另一个参数:
photos_patient_path(@patient, { :page => params[:page], :photoid => f.id })
创建:
http://localhost:3000/patients/79799/photos?page=2&photoid=15
但现在在我看来,我打电话:
<%= params[:photoid] %>
它什么也不返回,或者最好说为零!为什么?谢谢
【问题讨论】:
-
您在
params[]中看到了什么值? -
{"page"=>"2", "photoid"=>"15", "action"=>"photos", "controller"=>"patients", "id"=> "79799"}
-
在我的第一个链接中:photoid 在参数中是第一个
标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-4