‘id’ is passed into the controller and @chart is all the possible
records that have record_id = id.
My problem is this. I know there is only one chart w/ record_id = id.
But the search that i’ve done thinks that there could be a magnitude of
charts with record_id = id. I need to be able to find the chart that
has record_id = id so i can delete this chart.
From the view side, I was able to solve a similar sitiuation with
@chart.each do |chart|
if chart.record_id = id
‘delete’
end
Is there a way to do a similar for loop from the controller side?
‘id’ is passed into the controller and @chart is all the possible
records that have record_id = id.
My problem is this. I know there is only one chart w/ record_id = id.
But the search that i’ve done thinks that there could be a magnitude of
charts with record_id = id. I need to be able to find the chart that
has record_id = id so i can delete this chart.
From the view side, I was able to solve a similar sitiuation with
@chart.each do |chart|
if chart.record_id = id
‘delete’
end
Is there a way to do a similar for loop from the controller side?
Yngwie
How about @chart = Chart.find(:first, :conditions => [“record_id = ?”, param[‘id’]
]
This doesn¹t do any error checking and find_by_id will return a nil,
causing
an error if that id is not found so you might want to rescue it in case
somebody sneaks a bad id into this code.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.