Skip to content

Instantly share code, notes, and snippets.

@twestonkendall
Created November 27, 2012 21:45
Show Gist options
  • Save twestonkendall/4157296 to your computer and use it in GitHub Desktop.
Save twestonkendall/4157296 to your computer and use it in GitHub Desktop.
trying to get wicked routes to work
...
if @asset.save
redirect_to team_asset_asset_steps_path(@team, @asset)
# redirect_to team_path(@asset.team), :notice => "Your media was saved."
else
...
resources :teams, :path => '', :except => [:index] do
...
resources :assets, :path => '' do
resources :asset_steps
...
end
end
Started GET "/video-pros/213/asset_steps" for 127.0.0.1 at 2012-11-27 13:40:55 -0800
Processing by AssetStepsController#index as HTML
Parameters: {"team_id"=>"video-pros", "asset_id"=>"213"}
Redirected to http://0.0.0.0:3000/asset_steps/files
Completed 302 Found in 1ms
Started GET "/asset_steps/files" for 127.0.0.1 at 2012-11-27 13:40:55 -0800
Processing by AssetStepsController#show as HTML
Parameters: {"id"=>"files"}
Completed 404 Not Found in 44ms
ActiveRecord::RecordNotFound (Couldn't find Asset without an ID):
app/controllers/asset_steps_controller.rb:6:in `show'
@schneems
Copy link

I'm not sure if the index action is forwarding params properly, there might be a bug in there. You can use the direct path helper instead:

assets_asset_steps_path("files", asset_id: 213)

@twestonkendall
Copy link
Author

is this what you meant?
team_asset_asset_step_path(:team_id => @team.id, :asset_id => @asset.id, :id => "files")

@schneems
Copy link

yep, something along those lines should work. Just run rake routes to make sure you're using the right helper. I might suggest chaining your wizard controller to be named something else like "builder" or something along those lines so it would be team_asset_builder_path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment