Thanks guys..  Here is some further information to help you determine 
what the problem is..

*************Index View(Store)*******************

<% if @cameras.count > 1 then %>
  <% @cameratypes.each do |camera| -%>
  <% @image_url = find_first_in_group(camera.camtype)%>
  <%= link_to(image_tag(@image_url)) %>
  <div>
    <h3><%=h camera.camtype%></h3>
  </div>
  <% end %>
<% end %>

*************Store_controller*******************

class StoreController < ApplicationController
  def index
    @cameras = Camera.find_cameras_for_sale
    @cameratypes = Camera.find_cameras_by_camtype
    @cameramakes = Camera.find_cameras_by_make
  end

##This is only suppose to pass the value on to the main camera model
  def find_first_in_group(camtype)
    Camera.find_first_group_image(camtype)
  end
end

*************Camera model***********************
####Just an extract of the specific method being used


  def self.find_first_group_image(camtype)
    find(:first,
         :select => "image_url",
         :conditions => ["camtype = ?", camtype])
  end

****************Error message*******************

 NoMethodError in Store#index

Showing app/views/store/index.html.erb where line #5 raised:

undefined method `find_first_in_group' for 
#<ActionView::Base:0x7f6bef401980>

Extracted source (around line #5):

2:
3: <% if @cameras.count > 1 then %>
4:   <% @cameratypes.each do |camera| -%>
5:   <% @image_url = find_first_in_group(camera.camtype)%>
6:   <%= link_to(image_tag(@image_url)) %>
7:   <div>
8:     <h3><%=h camera.camtype%></h3>

************************************************

The code is supposed to step through all the different camera types and 
then look up the first table entry for every type.  It should then just 
extract the image_url value of that first entry of the unique camera 
type.  I then wish to turn this into clickable links which will display 
the camera models of every type.

I have managed to get this working by doing the SQL(find) from the index 
view, but will be penalized for my assignment if I leave it like that, 
because we are told to do all processing in the model itself.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to