hi there
how can an object be nil in line 37 but not nil in lines 34 & 40???
Parameters: {"activity_id"=>"7",
"action"=>"show", "id"=>"15",
"controller"=>"photos"}
User Columns (0.016000) SHOW FIELDS FROM users
User Load (0.000000) SELECT * FROM users WHERE (users.`id` = 1) LIMIT 1
Activity Columns (0.000000) SHOW FIELDS FROM activities
Activity Load (0.016000) SELECT * FROM activities WHERE (activities.`id`
= 7)
Photo Columns (0.016000) SHOW FIELDS FROM photos
Photo Load (0.000000) SELECT * FROM photos WHERE (photos.`id` = 15 AND (
photos.activity_id = 7))
Rendering template within layouts/application
Rendering photos/show
ActionView::TemplateError (You have a nil object when you didn''t expect
it!
The error occurred while evaluating nil.to_sym) on line #37 of
app/views/photos/show.html.erb:
34: <%= link_to image_tag(@photo.public_filename(:thumb)) %>
35:
36: <br>
37: <%= link_to "Download #{@photo.width} X #{@photo.height}",
download_photos_url(@photo, @activity) %>
38:
39: <br>
40: <%= link_to ''Edit'', activity_edit_photo_url(@activity,
@photo) %> |
-----------------------------------------------------------------------
This is photos_controller => show
def show
#@photo = Photo.find(params[:id])
@photo = @activity.photos.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @photo }
end
end
-------------------------------------------------------------------------
cheers
dion
--~--~---------~--~----~------------~-------~--~----~
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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Jean-Etienne Durand
2007-May-28 12:23 UTC
Re: nil objects that are not nil elsewhere in same scope
is @activity nil for example ? -- 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dion Hewson
2007-May-28 12:41 UTC
Re: nil objects that are not nil elsewhere in same scope
no,
I can do
<%= activity_photo_url(@activity, @photo)%>
in the line above the one that breaks and it works fine
I think my named route (download_photos_url) does not like taking
parameters, but am not sure why?!??!!
<%= link_to "Download", download_photos_url(@activity, @photo)
%>
http://localhost:2000/activities/7/photos/15
I am trying to get something like
http://localhost:2000/activities/7/photos/download/15
this is my routes.rb
map.resources :activities do |activity|
activity.resources :photos, :collection => {:download => :post }
end
map.resources :photos, :collection => {:download => :post }
cheers
dion
On 5/28/07, Jean-Etienne Durand
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> is @activity nil for example ?
>
> --
> 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Jean-Etienne Durand
2007-May-28 13:11 UTC
Re: nil objects that are not nil elsewhere in same scope
So, the problem is the following:
map.resources :photos, :collection => {:download => :post }
should be:
map.resources :photos, :member => {:download => :post }
since you pass the id of the photo (/activity/1/photos;download would be
the URI for the collection)
Why are you using a POST instead of a GET ?
Dion Hewson wrote:> no,
>
> I can do
>
> <%= activity_photo_url(@activity, @photo)%>
>
> in the line above the one that breaks and it works fine
>
> I think my named route (download_photos_url) does not like taking
> parameters, but am not sure why?!??!!
>
> <%= link_to "Download", download_photos_url(@activity, @photo)
%>
>
> http://localhost:2000/activities/7/photos/15
>
> I am trying to get something like
>
> http://localhost:2000/activities/7/photos/download/15
>
>
> this is my routes.rb
>
> map.resources :activities do |activity|
> activity.resources :photos, :collection => {:download => :post
}
> end
>
> map.resources :photos, :collection => {:download => :post }
>
> cheers
>
> dion
--
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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Dion Hewson
2007-May-28 14:12 UTC
Re: nil objects that are not nil elsewhere in same scope
jean,
thanks big time
works great
VIEW
<%= link_to "Download", activity_download_photo_url(@activity)
%>
ROUTES.RB
map.resources :activities do |activity|
activity.resources :photos, :member => {:download => :get }
end
map.resources :photos, :member => {:download => :get }
after looking at the server log, GET is obvious, but the strange thing is
that I have had this working without nested resources using POST...i''ll
have
to check that app again...
also member vs collection was the trick...which makes total
sense...sometimes you just can''t see the forest for the trees
once again, cheers heaps
you saved me a lot of troubles
dion
On 5/28/07, Jean-Etienne Durand
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> So, the problem is the following:
>
> map.resources :photos, :collection => {:download => :post }
>
> should be:
>
> map.resources :photos, :member => {:download => :post }
>
> since you pass the id of the photo (/activity/1/photos;download would be
> the URI for the collection)
>
> Why are you using a POST instead of a GET ?
>
> Dion Hewson wrote:
> > no,
> >
> > I can do
> >
> > <%= activity_photo_url(@activity, @photo)%>
> >
> > in the line above the one that breaks and it works fine
> >
> > I think my named route (download_photos_url) does not like taking
> > parameters, but am not sure why?!??!!
> >
> > <%= link_to "Download", download_photos_url(@activity,
@photo) %>
> >
> > http://localhost:2000/activities/7/photos/15
> >
> > I am trying to get something like
> >
> > http://localhost:2000/activities/7/photos/download/15
> >
> >
> > this is my routes.rb
> >
> > map.resources :activities do |activity|
> > activity.resources :photos, :collection => {:download =>
:post }
> > end
> >
> > map.resources :photos, :collection => {:download => :post }
> >
> > cheers
> >
> > dion
>
>
> --
> 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---