```ruby
class ActivitiesController < ApplicationController
	def index
		  @activities = Activity.all
	end

	def show
    if params[:id] =~ /\A\d+\z/
      @activity = Activity.find(params[:id])
      redirect_to activity_path(@activity)
    else
		  @activity = Activity.find_by(permalink: params[:id])
    end
	end
end
```

Fix exception when permalink is number
user
```ruby
class ActivitiesController < ApplicationController
  before_action :find_activity, only: [:show]
	def index
	  @activities = Activity.all
	end

	def show

	end

  protected

  def find_activity
    @activity = begin
                  Activity.find_by(permalink: params[:id])
                rescue ActiveRecord::RecordNotFound
                  Activity.find(params[:id])
                end
  end
end
```
assistant