Question

I've been following step by step example for wicked gem https://github.com/schneems/wicked/wiki/Building-Partial-Objects-Step-by-Step but I'm struggling to make it work

routes.rb

post '/trips/building/build(.:format)', :to => "trips/build#create"
resources :trips do
resources :build, controller: 'trips/build'
end

trips_controller.rb

class TripsController < ApplicationController
include Wicked::Wizard
before_action :set_trip, only: [:show, :update]
steps :basic, :details

def show
render_wizard
end

def create
@trip = Trip.create
redirect_to wizard_path(steps.first, :trip_id => @trip.id
end

def update
@trip.update_attributes(trip_params)
render_wizard @trip
end

private
def set_trip
  @trip = Trip.find(params[:trip_id])

end
def trip_params
....
end

end

index.html.erb

<%= link_to 'Create New Trip', '/trips/building/build', :method => :post, :class=>'btn btn-danger'%>

error in console:

Started POST "/trips/building/build" for 127.0.0.1 at 2014-04-16 22:50:20 -0700

ActionController::RoutingError - uninitialized constant Trips

this is driving me crazy... any thoughts?

Was it helpful?

Solution

Your controller is named incorrectly - your route is pointing to the Trips::BuildController but your controller is defined as the TripsController.

The link you shared defines a Products::BuildController so that's why it works there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top