Skip to content

Commit

Permalink
fixes routing for Rails 2.3 (and probably 3.0) - old coded caused
Browse files Browse the repository at this point in the history
weird error:  ActionView::TemplateError (undefined method `polymorphic_path' for #<ActionView: :Base:0x106c36778>)
  • Loading branch information
face committed Oct 25, 2010
1 parent 69f3f76 commit 9034e6e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
17 changes: 11 additions & 6 deletions README
Expand Up @@ -5,6 +5,7 @@ ActivityStreams is a Rails Plug-in providing a customizable framework
for cataloging and publishing user activity and social objects.

Developed and tested on Rails 2.1
Tested on Rails 2.3.10

Example
=======
Expand All @@ -15,11 +16,15 @@ Example

The only option is the name of the model that holds your User.

2) Run the migration
2) Add the Routes, in routes.rb

map.activity_streams

3) Run the migration

rake db:migrate

3) Edit ./config/initializers/activity_streams.rb. Here you
4) Edit ./config/initializers/activity_streams.rb. Here you
must define your on list of ACTIVITY_STREAM_ACTIVITIES.
ACTIVITY_STREAM_ACTIVITIES are a hash of activities used on the
entire site. ACTIVITY_STREAM_ACTIVITIES are a grouping of activities
Expand All @@ -36,7 +41,7 @@ need changing. However, set ACTIVITY_STREAM_USER_MODEL_NAME to be
the method of your user model the returns a friendly name (like
"firstname lastname").

4) Edit application controller and include the activity logger:
5) Edit application controller and include the activity logger:

class ApplicationController < ActionController::Base

Expand All @@ -45,7 +50,7 @@ the method of your user model the returns a friendly name (like
#...


5) Add logging calls to each controller for all the actions you
6) Add logging calls to each controller for all the actions you
want to log activities. For example:

class FeedsController < ApplicationController
Expand Down Expand Up @@ -109,7 +114,7 @@ The arguments for log activity stream are
or method.


6) Display a stream in one of your views. For example, from
7) Display a stream in one of your views. For example, from
./app/views/users/show.html.erb:
<h3>Recent Activity</h3>

Expand All @@ -119,7 +124,7 @@ The arguments for log activity stream are

</div> <!-- hfeed -->

7) Define the required methods. The plug-in needs to know the current logged in user and if that user is an admin. So the following methods must be defined.
8) Define the required methods. The plug-in needs to know the current logged in user and if that user is an admin. So the following methods must be defined.

a) The User model needs an "admin?" method

Expand Down
1 change: 1 addition & 0 deletions init.rb
Expand Up @@ -5,6 +5,7 @@
#++
# Activity Streams Intitialization
require 'activity_streams'
require 'activity_streams/routes'

ActionController::Base.append_view_path(File.join(File.dirname(__FILE__), "views"))

Expand Down
27 changes: 11 additions & 16 deletions lib/activity_streams/routes.rb
Expand Up @@ -5,22 +5,17 @@
#++
# routes.rb adds additional routes for ActivityStreamsModule
#
class ActionController::Routing::RouteSet # :nodoc:
def draw # :nodoc:
clear!
mapper = Mapper.new(self)

activity_stream_maps(mapper)

yield mapper

install_helpers
module ActivityStreams #:nodoc:
module Routing #:nodoc:
module MapperExtensions
def activity_streams
@set.add_named_route('your_activities', '/feeds/your_activities/:activity_stream_token', :controller => 'activity_streams', :action => 'feed', :format => 'atom')
resources :activity_stream_preferences
resources :activity_streams
end
end
end
end

def activity_stream_maps(map) # :nodoc:
map.your_activities '/feeds/your_activities/:activity_stream_token', :controller => 'activity_streams', :action => 'feed', :format => 'atom'
map.resources :activity_stream_preferences
map.resources :activity_streams
end
ActionController::Routing::RouteSet::Mapper.send :include, ActivityStreams::Routing::MapperExtensions

end

0 comments on commit 9034e6e

Please sign in to comment.