Generic-user-small Allen Walker 19 posts

I’m trying to had a new action to my “actitivites” controller.

activities_controller.rb

...

def view
...
end

...
---

When I try to access the following URL: http://apps.new.facebook.com/myapp/activities/view

it returns:

Unknown action

No action responded to show


Also the following “link_to” breaks:

link_to(“Attendees:”, activities_path(:id => activity, :controller => :activities, :action => :view))%>

with error:

ActionController::RoutingError in Public#index

Showing /public/index.fbml.erb/ where line #25 raised:

ActionView::TemplateError (activities_url failed to generate from {:controller=>”activities”, :action=>”view”, :id=>#<activity 60 id:>


my routes.db:
..
map.resources :activities
..


I seem to not be able to specify create “actions” that can be accessed thru my controller. I think there is something I’m missing here.

Thanks

 
Head_small Mike Mangino 148 posts

This isn’t really specific to Facebook, but you need to define actions in routes.rb. This would be:


  map.resources :actions, :member=>{:view=>:get}

If you are showing an action, you probably want to use the show method. If you’re new to RestFul Rails, I would check out the screencast mentioned in the book. It really helped me understand the concepts and comes with a great one page chart of routes.

2 posts, 2 voices