Colin Law wrote in post #954895:
> On 17 October 2010 06:17, Evanoshki Brataslavainskinski
> <li...@ruby-forum.com> wrote:
>> Luke Cowell wrote in post #954878:
>>> Did you try Michael's suggestion of adding this to your controller?
>>>
>>> helper_method :find_first_in_group
>>>
>>> This probably isn't the best approach, but you could change line 5 to
>>> something like this:
>>> <% @image_url = Camera.find_first_group_image(camera.camtype)%>
>
> It is generally not considered good practice to access model methods
> directly from the view.  Possibly a better way would be to define an
> instance method, image_url, in the Camera class.  Then you could say
> <%= link_to(image_tag(camera.image_url)) %>

Right.  Colin is being nice, so I'll be less nice: the view should NEVER 
EVER EVER touch the database.

I am beginning to think that, for this reason and others, template 
languages (such as Mustache) where you can't call *any* model methods 
are the way to go...

>
> Colin

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to