RailsCasts Pro episodes are now free!

Learn more or hide this

Lyle Troxell's Profile

GitHub User: lyle

Site: http://lyle.troxell.com/

Comments by Lyle Troxell

Avatar

I ended up doing this, doesn't look elegant, but it works.

ruby
  ActiveAdmin.routes(self)
  
  
  get '/admin/episodes/:id', :controller => "admin/episodes",
      :action => 'show', :id => /[0-9]+\/[0-9]+\/[0-9]+/
  get '/admin/episodes/:id/edit', :controller => "admin/episodes",
          :action => 'edit', :id => /[0-9]+\/[0-9]+\/[0-9]+/
  put '/admin/episodes/:id', :controller => "admin/episodes",
              :action => 'update', :id => /[0-9]+\/[0-9]+\/[0-9]+/
  delete '/admin/episodes/:id', :controller => "admin/episodes",
              :action => 'destroy', :id => /[0-9]+\/[0-9]+\/[0-9]+/
Avatar

I am trying to use friendly_id with ActiveAdmin and I am sending friendly_id in my model a function showdate_as_url

ruby
  def showdate_as_url
    "#{showtime.strftime("%Y/%m/%d")}"
  end

to get this to work I have this in my routes:

ruby
  resources :episodes, :id => /[0-9]+\/[0-9]+\/.+/

All works great outside of active admin, but in the active admin scope this date based url dose not work. I have tried setting the to_param back to id with a before filter in active admin - which works again, but then leaving active admin my friendly_id does not work any more.

Any ideas anyone?